You can generate a schema from a DataSet, so either construct one in code or
Fill one with a DataAdapter and call the GetXmlSchema function which returns
it as a string.
e.g:
DataSet ds = new DataSet();
ds.Tables.Add(" table 1");
ds.Tables[0].Columns.Add("c ol1", typeof(int));
ds.Tables[0].Columns.Add("c ol2", typeof(DateTime ));
ds.Tables[0].Columns.Add("c ol3", typeof(string)) ;
ds.Tables[0].Columns.Add("c ol4", typeof(Guid));
File.WriteAllTe xt("C:\\sch.xsd ",ds.GetXmlSche ma());
this makes:
<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="NewDataSet " xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSe t" msdata:IsDataSe t="true"
msdata:UseCurre ntLocale="true" >
<xs:complexType >
<xs:choice minOccurs="0" maxOccurs="unbo unded">
<xs:element name="table_x00 20_1">
<xs:complexType >
<xs:sequence>
<xs:element name="col1" type="xs:int" minOccurs="0" />
<xs:element name="col2" type="xs:dateTi me" minOccurs="0" />
<xs:element name="col3" type="xs:string " minOccurs="0" />
<xs:element name="col4" msdata:DataType ="System.Gui d,
mscorlib, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= b77a5c561934e08 9"
type="xs:string " minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"sippyuconn " wrote:
Hi
In C# ide if you have a SqlServer attached and Create a New XSD Item in a
solution you can then drag a db from the SQLServer and ti creates a XSD
modelled after the db. Can this be done thru code???
If I have a EXE that is passed a db can I generate a XSD on the fly???
Thanks