inserting asp variables in select sql statements

Results 1 to 3 of 3

Thread: inserting asp variables in select sql statements

  1. #1
    Join Date
    Dec 1969

    Default inserting asp variables in select sql statements

    hello!<BR>can anyone help in inserting variables in select conditons....I would like to know the correct format or syntax in doing one. I tried to insert variables created from request.querystrings but with out success. The code that i am particularly working with looks something like this:<BR><BR>----------------------<BR>&#060;% <BR><BR>hello=request.querystring("ID")<BR>hello1= request.querystring("pic")<BR>hello2=request.query string("big")<BR><BR>Set MyConn=Server.CreateObject("ADODB.Connection")<BR> MyConn.Open "getData"<BR><BR>SQL= "Select trees, type, ID, Password From demo" _<BR> & "Where type=&#039;"&hello&"&#039;"<BR><BR>Set RS=MyConn.Execute(SQL)<BR><BR> Response.Write(RS.Fields("trees").value)<BR><BR> <BR><BR><BR>%&#062;<BR><BR><BR>&#060;% <BR>RS.Close<BR>MyConn.Close<BR>Set RS = Nothing<BR>Set MyConn = Nothing<BR><BR>%&#062;<BR>----------------------------<BR><BR>If you would look at the select statement at the SQL part, i inserted the "hello" variable as one of my conditions in selecting the rows and columns that i would like to get data from. But whenever i execute the asp page, i always receive an erro page.<BR><BR>any help fgrom you guys will be highgly appreciated thank you!<BR><BR>Willmar Brin

  2. #2
    Join Date
    Dec 1969

    Default &h is hex

    The &h is interpreted as the beginning of a hex constant in vb-script. If you insert a space it should be better. Also, you need an extra space in your sql statement, between the table name and the where clause.<BR><BR>SQL= "Select trees, type, ID, Password From demo" _ <BR>& " Where type=&#039;"& hello&"&#039;" <BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default do provide the ERROR sattement for god..

    You should provide the error string as well.<BR>This guy has found out by hiimself wht error could be there. n replied you..<BR>There can be another error as well.. <BR><BR>that I will tell u only when u post the ERROR ,,.:)

Posting Permissions

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