1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| public static void GenerateXsd(string aConnectionString, string aTableName, string aPathDestination,string aNameSpace, string aDataSetName)
{
SqlConnection sqlConnection = new SqlConnection(aConnectionString);
SqlDataAdapter dataAdapter = new SqlDataAdapter("Select * from " + aTableName, sqlConnection);
DataSet ds = new DataSet();
try
{
ds.DataSetName = aTableName;
ds.Namespace = aNameSpace;
dataAdapter.FillSchema(ds, SchemaType.Source, aTableName);
string filename = Path.Combine(aPathDestination, aTableName + ".xsd");
ds.WriteXmlSchema(filename);
Console.WriteLine("The XSD schema is written to " + filename);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
//Console.ReadLine();
} |
Partager