more ASP and SQL

Results 1 to 2 of 2

Thread: more ASP and SQL

  1. #1
    Chris Giesler Guest

    Default more ASP and SQL

    Hello again. A couple of posts down, I asked how I would pass a variable from ASP to SQL. Hats off to Eric, who gave this reponse:<BR><BR>&#060;%<BR>strvariable = Request.Form("variable")<BR><BR>sqlText = "SELECT * FROM TableA "<BR>sqlText = sqlText & " WHERE variable=" & strvariable & ";"<BR>%&#062;<BR><BR>I see why this SHOULD work, but it isn&#039t. I think I may be using an incorrect Cursor Type or Lock Type. However, I am so new to SQL that I am not sure. The code shown below is what I started with. So my question is, how would I combine that with the code Eric gave me?<BR><BR>Thanks again.<BR><BR>&#060;%<BR>set rstMain = CreateObject("ADODB.Recordset")<BR>rstMain.Open "SQL STATMENT HERE", "DSNMain",2, 3<BR><BR>rstMain.addnew<BR>rstMain("variable") = 100<BR><BR>rstMain.update<BR>rstMain.close<BR>set rstMain = nothing<BR>%&#062;

  2. #2
    fl1rt Guest

    Default RE: more ASP and SQL

    I usually add a "&#039" around the required variable to construct a string. ie:<BR><BR>sqlText = sqlText & " WHERE variable=&#039" & strvariable & "&#039;"<BR>or<BR><BR>sqlText = sqlText & " WHERE variable=" & "&#039" & strvariable & "&#039" & ";"<BR><BR>I&#039m not sure if this works in this case, but give it a try.

Posting Permissions

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