Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

another variable [unknown column]... 1

Status
Not open for further replies.

burnside

Technical User
Dec 4, 2004
236
GB
hi,
hav put variables in my WHERE statements before
and not had a prob...however

1)get vars from page

Code:
x_userlogin = request.Form("x_userlogin")
x_userpw = request.Form("x_userpw")

2)next put some quotes round them
Code:
x_userlogin = "" & x_userlogin & ""
x_userpw = "" & x_userpw & ""

3)next the query and run it
Code:
strsql2 = "SELECT * FROM tbl_users"
strsql2 = strsql2 & " WHERE userlogin = " & x_userlogin
strsql2 = strsql2 & " AND userpw = " & x_userpw
Set rs = conn.Execute(strsql2)

then get error
Code:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
Unknown column 'mjg' in 'where clause'
/dfasp2/stockviewmain.asp, line 33

4)statement looks like
Code:
SELECT * FROM tbl_users WHERE userlogin = mjg AND userpw = pw

can someone tell me where am i missing the quotes?
 
Step 2 doesn't accomplish anything and shoudl be omitted

Code:
strsql2 = "SELECT <columnsOfInterest> FROM tbl_users"
strsql2 = strsql2 & " WHERE userlogin = '" & _
replace(x_userlogin,"'","''")
strsql2 = strsql2 & "' AND userpw = '" & _
replace(x_userpw,"'","''") & "'"
Set rs = conn.Execute(strsql2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top