using a Querystring in a SQL statement

Results 1 to 3 of 3

Thread: using a Querystring in a SQL statement

  1. #1
    Join Date
    Dec 1969

    Default using a Querystring in a SQL statement

    How do I write a select query using a querystring in the SQL (WHERE username = Querystring)<BR><BR>And how do I display the results of the query, can I also use set the results as session variables all on one page?

  2. #2
    Jason Buck Guest

    Default RE: using a Querystring in a SQL statement

    Here you go:<BR><BR>The first thing you do is get the querystring and make it a string on this page.<BR><BR>Then you write the SQL statement to use the string that you created on this page.<BR>&#060;%<BR><BR><BR>strClientID = request.querystring("climat")<BR>Response.write strClientID<BR>strConnect22 = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=C:database e1.mdb"<BR><BR>dim objconn22, objrec22, mysql22, strStatus22, Mytest22, strLength22<BR>set objconn22 = server.createobject("ADODB.Connection")<BR><BR><BR > strConnect22<BR><BR><BR>mysql22 = "SELECT trust.TClimat, Trust.Truname FROM Trust WHERE (((Trust.TClimat)=&#039" & strClientID & "&#039)) ORDER BY Truname;"<BR><BR><BR><BR><BR>set rstemp22=objConn22.execute(mysql22)<BR><BR>I hope that this has helped you. If not please feel free to contact me.<BR><BR>Respectfully,<BR><BR>Jason<BR>webmaster<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: using a Querystring in a SQL statement

    I am under the assumption that you want the querystring base on what the user entered from the previous form. Within your previous form, set IDfield="User_ID". Then, in the next page, set User_ID to a variable like this: <BR><BR>Form_ID = request.querystring("User_ID")<BR><BR><BR>SQLusern ame="SELECT field1 FROM table WHERE field1=" & Form_ID<BR><BR>response.write SQLusername &#039see if SQL statement is returning correct querystring<BR>set oRs=DbObj.execute(SQLusername)

Posting Permissions

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