Results 1 to 5 of 5

Thread: Two Database Queries

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    183

    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.

  2. #2
    Member
    Join Date
    Dec 2000
    Location
    UK
    Posts
    39
    Try DataAdapter.SelectCommand property and then use the Fill method to execute the query

  3. #3
    Lively Member
    Join Date
    Jul 2002
    Location
    Gateshead, UK
    Posts
    101

    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?
    <% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>

  4. #4
    Lively Member
    Join Date
    Aug 2002
    Location
    outerspace
    Posts
    126
    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
    "All those who wonder are not lost" -j.r.r tolkien

  5. #5
    Lively Member
    Join Date
    Jul 2002
    Location
    Gateshead, UK
    Posts
    101

    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?
    <% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width