using System;
using System.Data;
using System.Data.SqlClient;
class Program
{
static void Main(string[] args)
{
string sqlConnectString = "Data Source=(local);" +
"Integrated security=SSPI;Initial Catalog=AdventureWorks;";
string sqlSelect = "SELECT ContactID,FirstName, LastName FROM Person.Contact";
SqlDataAdapter da = new SqlDataAdapter(sqlSelect, sqlConnectString);
DataSet ds = new DataSet( );
da.Fill(ds, "Contact");
Console.WriteLine("GetXmlSchema( ) = {0}", ds.GetXmlSchema( ));
DataSet dsSchema = new DataSet( );
da.FillSchema(dsSchema, SchemaType.Source, "Person.Contact");
da.Fill(dsSchema, "Contact");
Console.WriteLine(dsSchema.Tables.Count);
Console.WriteLine("GetXmlSchema( ) = {0}", dsSchema.GetXmlSchema( ));
}
}
|