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.
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.