Actually I am not able to get what the error is all about. So please guide me.
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);
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

Roei BarRank #1,271 · 1.4K reputationPosted Oct 5, 2009, 5:49 AM EDT
Shital Mandlecha19 reputationPosted Oct 5, 2009, 8:19 PM EDT
Even though i am using Try-Catch block, it is still giving the error.
Thanks in advance.
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 6, 2009, 1:08 AM EDT
and Dont Forget to mark "Do you like answer" please it will give me some credits :)
protected void Button1_Click(object sender, EventArgs e) { string connString = @"server = .\sqlexpress;integrated security = true;database = northwind"; SqlConnection conn = new SqlConnection(connString); try { conn.Open(); SqlCommand comm = new SqlCommand("select productname,unitprice from products",conn); SqlDataAdapter da = new SqlDataAdapter(comm); 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(); }