when i run a query like this:
SqlDataAdapter dap = new SqlDataAdapter("select * from some table", myConnection);
before doing the select, should i be doing "use somedatabase; go" ??
when i run a query like this:
SqlDataAdapter dap = new SqlDataAdapter("select * from some table", myConnection);
before doing the select, should i be doing "use somedatabase; go" ??
I imagine myConnection is already specifying a default catalog (i.e. database) in its connection string, so you don't need to use the use line.
See here for details.
That should all be in the myConnection variable, since I presume that contains the connection string.
Although you might want to call using on the DataAdapter
using(SqlDataAdapter dap = new SqlDataAdapter("select * from some table", myConnection)
{
//do stuff with dap here
}//dispose of dap
Since it does inherit from something that implements IDisposable.