A
Alex
When I use SqlCommand directly instead of using DataAdapter/DataSet model,
f.e. I open the connection, execute the query and then close it virtually
right away(the exception handling should it get there is just a few
instructions). Isn't this really what DataAdapter does underneath, I'm just
not going through the DataAdapter wrapper? Btw, does the Connection time out
have a default value?
SqlConnection conn = new SqlConnection(connString);
SqlCommand procAddCustomer = new SqlCommand("procAddCustomer", conn);
procAddCustomer.CommandType = CommandType.StoredProc;
// Add parameters to comand's parameters collection
.....
conn.Open();
try
{
procAddCustomer.ExecuteNonQuery();
}
catch(SqlException e)
{
// handle exception
}
finally
{
conn.Close();
}
f.e. I open the connection, execute the query and then close it virtually
right away(the exception handling should it get there is just a few
instructions). Isn't this really what DataAdapter does underneath, I'm just
not going through the DataAdapter wrapper? Btw, does the Connection time out
have a default value?
SqlConnection conn = new SqlConnection(connString);
SqlCommand procAddCustomer = new SqlCommand("procAddCustomer", conn);
procAddCustomer.CommandType = CommandType.StoredProc;
// Add parameters to comand's parameters collection
.....
conn.Open();
try
{
procAddCustomer.ExecuteNonQuery();
}
catch(SqlException e)
{
// handle exception
}
finally
{
conn.Close();
}