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 DataSets 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.
|
| | Msgs 1 to 4 of 4 (Total in Forum: 4) (Refresh) | FirstPrevNext |
|
 |
|
 |
hi, this is a fine idea that i would be very interested in seeing fully implemented. i don't know why they didn't include it in the .net framework already.
hope you get time to put more work into it. i would certainly use it. thanks, tim.
|
|
|
|
 |
|
 |
What is the point of posting an article with classes that throw Not Implemented exceptions. While the idea is a good one, you project example does absolutely nothing to help anyone!!
|
|
|
|
 |
|
 |
I appreciate your comment, but the Caveat section clearly states what is not implemented. I only implemented the parts of hte provider I needed for my project. I've been meaning to get back to it, but it'll be a while before I can get to it.
|
|
|
|
 |
|
 |
Shawn,
Did you ever get a chance to add to this. Here's what I'm trying to do...I want to load a dataset from an xml file. Then I need to make some changes to the dataset then insert those changes into a brand new datasource...will any of this code do that?
|
|
|
|
 |
|
|
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+PgUp/PgDown to switch pages.