2 SQL queries in 1 asp page -- Newbie

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default 2 SQL queries in 1 asp page -- Newbie

    I am trying to run 2 queries against a Access2k database on a single ASP
    page. I have one query working beautifully, but am not sure how to
    execute the second one.

    At the top of the ASP page, I have:
    DIM objConn
    SET objConn=Server.CreateObject("ADODB.Connection")
    objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" &_
    "DBQ=" & DBPath
    objConn.Open
    Dim strSQL
    strSQL = "First SQL statement"
    DIM objRS
    SET objRS=Server.CreateObject("ADODB.Recordset")
    objRS.Open strSQL, objConn

    -- Data manipulation / Recordset write out --

    At the end of the ASP, I have
    objRS.Close
    SET objRS=Nothing
    objConn.Close
    Set objConn=Nothing

    Where and with what code should I insert to execute the 2nd SQL
    statement?

    Thanks in advance.


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Micromanaged Guest

  2. Similar Questions and Discussions

    1. Queries Of Queries Single Quote Problem
      When using queries of queries I'm having the following issue. Select Company_ID From qry_MyQuery Where Company_NM = 'MyString''s' <----...
    2. Newbie Question - Two on One Page
      How do I use acrobat and change my pdf so that I have two of the same document on one page. Do I need a plugin and if so which one? All help is...
    3. A bundle of newbie queries
      I've finally overcome my newbie embarrassment enough to post about actual code -------------------- After a couple of years(!) of about-to, I...
    4. newbie: asp page templatess
      hi i am quite new to .net and am trying to implement page templates but i just cant seem to get it to work, and i dont quite follow the examples on...
    5. HELP! Dreamweaver MX running delete queries at top of page!
      OK. Seeing that noone is replying to the post on Macromedia web site I thought I might try here. Has anyone seen this problem before. It's really...
  3. #2

    Default Re: 2 SQL queries in 1 asp page -- Newbie

    Micromanaged wrote:
    > I am trying to run 2 queries against a Access2k database on a single
    > ASP page. I have one query working beautifully, but am not sure how
    > to execute the second one.
    >
    > At the top of the ASP page, I have:
    > DIM objConn
    > SET objConn=Server.CreateObject("ADODB.Connection")
    > objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};"
    > &_ "DBQ=" & DBPath
    > objConn.Open
    > Dim strSQL
    > strSQL = "First SQL statement"
    > DIM objRS
    > SET objRS=Server.CreateObject("ADODB.Recordset")
    > objRS.Open strSQL, objConn
    >
    > -- Data manipulation / Recordset write out --
    >
    > At the end of the ASP, I have
    > objRS.Close
    Depends on what you want to do with it, but this looks like a good place for
    it ...
    > SET objRS=Nothing
    > objConn.Close
    > Set objConn=Nothing
    >
    > Where and with what code should I insert to execute the 2nd SQL
    > statement?
    >
    > Thanks in advance.
    >
    >
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  4. #3

    Default Re: 2 SQL queries in 1 asp page -- Newbie

    Im newish to asp myself so i dont know if this is the best way but it works
    on the pages I have done

    Create a second recordset & sql string i.e.
    (you may be able to set objRS to nothing and open it again calling the other
    sql string)

    Dim strSQL1
    strSQL1 = "Second SQL statement"
    DIM objRS1
    SET objRS1=Server.CreateObject("ADODB.Recordset")

    and then call it

    objRS1.Open strSQL1, objConn

    render the data

    objRS1.Close
    SET objRS1=Nothing


    hope the above is of use

    J



    "Micromanaged" <novirus@nospam.org> wrote in message
    news:uWOXphQREHA.4020@TK2MSFTNGP11.phx.gbl...
    > I am trying to run 2 queries against a Access2k database on a single ASP
    > page. I have one query working beautifully, but am not sure how to
    > execute the second one.
    >
    > At the top of the ASP page, I have:
    > DIM objConn
    > SET objConn=Server.CreateObject("ADODB.Connection")
    > objConn.ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)};" &_
    > "DBQ=" & DBPath
    > objConn.Open
    > Dim strSQL
    > strSQL = "First SQL statement"
    > DIM objRS
    > SET objRS=Server.CreateObject("ADODB.Recordset")
    > objRS.Open strSQL, objConn
    >
    > -- Data manipulation / Recordset write out --
    >
    > At the end of the ASP, I have
    > objRS.Close
    > SET objRS=Nothing
    > objConn.Close
    > Set objConn=Nothing
    >
    > Where and with what code should I insert to execute the 2nd SQL
    > statement?
    >
    > Thanks in advance.
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    monki Guest

  5. #4

    Default Re: 2 SQL queries in 1 asp page -- Newbie

    I usually close and destroy objRS after each SQL statement instead of
    just once at the end of the page.

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Consultant
    [url]http://www.Bullschmidt.com[/url]
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Devdex [url]http://www.devdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139