Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSD and DataSet question

Status
Not open for further replies.

ccampbell

Programmer
Aug 16, 2001
201
US
Hello,
I am new to C# but have programmed in C++ for a long time. I am trying to retrieve data from a database and output it into an XML file. I have been given an XSD to use as a template so I know what format the outputed XML file should be in. Right now I am performing the following functions

//Variables have been previously created.

connect.Open();

myStreamReader = new StreamReader("T0020V1.xsd");
myDataSet.ReadXmlSchema(myStreamReader);

StringBuilder sqlString = new StringBuilder("Select * from Temp"); SqlDataAdapter adapter = new SqlDataAdapter(sqlString.ToString(), connect);

adapter.Fill(myDataSet);

connect.Close();

FileStream fs = new FileStream("Test.xml",FileMode.OpenOrCreate,FileAccess.Write);
myDataSet.WriteXml(fs);
fs.Close();

It works as far as reading data and writing XML out, but it does not write the XML out according to the schema that I provide it with. Does anyone know how to use an XSD schema to get the desired XML output? Thanks for any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top