日期:2014-05-18 浏览次数:20848 次
SqlConnection str = new SqlConnection("server=.;database=db_test;Trusted_Connection=true"); string str1 = "select 雇员ID,姓氏,头衔 from student"; str.Open(); DataSet dt = new DataSet(); SqlDataAdapter da1 = new SqlDataAdapter(str1, str); da1.Fill(dt); dt.WriteXmlSchema("C:\\ttt.xml"); //dt.WriteXml("C:\\tt.xml"); Console.Write("OK!"); str.Close();
<?xml version="1.0" standalone="yes"?> <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element name="Table"> <xs:complexType> <xs:sequence> <xs:element name="雇员ID" type="xs:short" minOccurs="0" /> <xs:element name="姓氏" type="xs:string" minOccurs="0" /> <xs:element name="头衔" type="xs:string" minOccurs="0" /> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element> </xs:schema>
using System.Xml; //... XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(&qu