Introduction
This is my first attempt at writing a Managed Provider. The idea behind it was
to allow users of the Managed Provider to be able to fill DataSet
s from XML in
a homogeneous way. This way you could mix XML and database data together
without having to know exactly which is from which.
Usage Notes
- The Connection string for the
XmlConnection
class takes a URL or File path to
an XML file.
- The
XmlCommand
class takes an optional XPath
expression to decide which subset
of the XML file to include in the DataSet
.
Example
static void TestXml(string URL, string XPath, string indent, string Title)
{
Console.WriteLine("Testing {0} \nwith XML Source: {1}", Title, URL);
XmlDataAdapter da = new XmlDataAdapter(XPath, new XmlConnection(URL));
da.SelectCommand.Connection.Open();
DataSet ds = new DataSet();
int rowsAffected = da.Fill(ds);
Console.WriteLine(indent + "Filled DataSet with {0} rows", rowsAffected);
string xml = ds.GetXml();
DataTable[] aTables = da.FillSchema(ds, SchemaType.Source);
Console.WriteLine(indent + "Filled DataSet with {0} tables of Schema only",
aTables.GetLength(0));
if (XPath != "/") Console.WriteLine(indent + "XPath Results: \n{0}", xml);
}
Caveats
- The
DataReader
was never implemented.
- This Managed Provider is read-only. If you need to write with it, please
contact me as I might be able to get something working.
- When using an
XPath
expression in the XmlCommand
class, only the first Match is
loaded into the DataSet
.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.