protected void Button1_Click(object sender, EventArgs e)
{
string connString = @"server = .\sqlexpress;integrated security = true;database = northwind";
string qry = @"select productname,unitprice from products";
SqlConnection conn = new SqlConnection(connString);
try
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand(qry, conn);
conn.Open();
DataSet ds = new DataSet();
da.Fill(ds, "products");
Console.WriteLine("Creating");
ds.WriteXml(@"c:\productstable.xml");
Console.WriteLine("Done");
}
catch (Exception e1)
Console.WriteLine("Error: " + e1);
finally
conn.Close();
Error!
The thread 0xba4 has exited with code 0 (0x0).
A first chance exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll