Full Version: With .net, how to associate a c# DataSet to an xml schema
UtterAccess Discussion Forums > And More... > JAVA and C#
gunderj
Hello,
Is anyone familiar with basing a c# DataSet on an xml schema? As I understand it, you can create the DataSet object, then associate to an xml schema (.xls), then when the DataSet is loaded with the xml transaction it will have alll the xml elements in it.
My code to do this is giving the error:
"The schema namespace is invalid. Please use this one instead: http://www.w3.org/2001/XMLSchema.
at System.Data.DataSet.ReadXmlSchema(XmlReader reader, Boolean denyResolving)
at System.Data.DataSet.ReadXmlSchema(TextReader reader)
at postReturn.Page_Load(Object sender, EventArgs e)”

I created the schema file from a very simple query export from Microsoft Access 2002 and I did edit this file to change the namespace from http://www.w3.org/2000/10/XMLSchema (given from the MS Access export) to http://www.w3.org/2001/XMLSchema (as suggested by the error message).

Here is the c# code to associate the DataSet to the schema:

try
{
string sch = Server.MapPath("mySchema.xls”);
System.IO.StreamReader myStreamReader = new System.IO.StreamReader(sch);
ds.ReadXmlSchema(myStreamReader);
myStreamReader.Close();
}
catch (Exception ex)
{
Response.Write("ERROR dataSet did not associate to schema: " + ex.ToString());
throw ex;
}

But, this did not help - I still get the same error message complaining about the namespace.
Much appreciation if someone can shed some light on this,
Jay
datAdrenaline
I am assuming from you post on 2009-09-04 you would able to work this out?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.