-
Two Database Queries
ok, I can run one database query easy enough, but what if I want to run a second query (a different one) right after on the same database, do I need to recreate a whole new set of variables? Here is kinda what I want to do....
string strConnection = "server=localhost; uid=; pwd=; database=DBr";
string strCommand = "SELECT * FROM Table 1";
SqlDataAdapter dataAdapter = new SqlDataAdapter(strCommand,strConnection);
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet,"WebLog");
SqlCommandBuilder bldr = new SqlCommandBuilder(dataAdapter);
DataTable dataTable = dataSet.Tables[0];
now I want to query the same database again with a different strCommand.
-
Try DataAdapter.SelectCommand property and then use the Fill method to execute the query
-
Unknown territory...
Erm - I think I am treading in unknown waters, with the SQLAdaptor stuff etc - but is all that really necessary? I don't have any problems just db.Execute'ing another SQL statement - if it provides an RS like SELECT, then just use a different variable? If I'm talking utter newbie rubbish here, can someone explain?
-
if your using asp.net you should proablly also move to ado.net just a thought if your just using asp then use ado. With .net it only makes sense to start using ado.net being that it alows faster and disconnect access to datasets
-
Ah
I thought that DB script looked a little different lol!
The thing is, I'm on Brinkster (free ASP host); only think I can use ASP... Anyone got any URLs of good ADO tutorials though?