I have the following bit of code:
using(DataSet ds = db.ExecuteDataSet(cmd)) {
// Return the DataTable
return ds.Tables[0];
}
I know that creating an instance in a using statement will ensure that Dispose is called on the object when the using statement is exited. However, I'm confused as to where I can implement a try/catch block here.
Suppose that the network link goes down between the web server and the database server. I've tested this, and it throws a SQLException. However, I am not sure where I can include a try/catch block here. Would it go inside the parentheses of the using statement, or in the body of it?
using(DataSet ds = db.ExecuteDataSet(cmd)) {
// Return the DataTable
return ds.Tables[0];
}
I know that creating an instance in a using statement will ensure that Dispose is called on the object when the using statement is exited. However, I'm confused as to where I can implement a try/catch block here.
Suppose that the network link goes down between the web server and the database server. I've tested this, and it throws a SQLException. However, I am not sure where I can include a try/catch block here. Would it go inside the parentheses of the using statement, or in the body of it?