using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Xsl;
using System.Xml.XPath;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Collections;
using System.Globalization;
using System.Net;
using System.Text.RegularExpressions;
namespace astuanax
{
///
///
public class Library
{
private static string _ErrorMessage = "";
/*
* This method is enabling debug information to be passed along
* doing them umbraco situps..
*/
public static string ErrorMessage()
{
return _ErrorMessage;
}
///
/// Query a database other then the Umbraco database
///
/// server - database - username - password
/// sql query
/// XML dataset
public static XPathNodeIterator QueryDatabase(string conn, string query )
{
try
{
SqlConnection thisConnection = new SqlConnection(conn);
//@"Server=127,0,0,1;Database=Northwind;User ID=****;Password=****;Trusted_Connection=False");
thisConnection.Open();
SqlCommand thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = query;
SqlDataAdapter adapter = new SqlDataAdapter(thisCommand);
DataSet ds = new DataSet();
adapter.Fill(ds);
thisConnection.Close();
//return ds.GetXml();
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(ds.GetXml());
XPathNavigator xp = xdoc.CreateNavigator();
return xp.Select(".");
}
catch (SqlException e)
{
_ErrorMessage = e.Message;
return null;
}
}
}
}