I saw that in most samples SqlCommand was used like this
using (SqlConnection con = new SqlConnection(CNN_STRING))
{
using (SqlCommand cmd = new SqlCommand("Select ID,Name From Person", con))
{
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds =new DataSet();
da.Fill(ds);
return ds;
}
}
I know why we are using "using" statement. But SqlCommand doesn't inlcude Close() method, so should we really use it within using statement
Pravesh Singh
18-Aug-2014