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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variables in SQL query

Status
Not open for further replies.

mortkc

MIS
Apr 23, 2001
84
US
Can I use a variable instead of a value from the database?

Here is my example: "SELECT * FROM Customers WHERE CustomerID = 'Smith'"

Can I replace Smith with the value from a variable that was passed from a user input?

Thanks
 
Yes i think so. It would be something like this
 "SELECT * FROM Customers WHERE CustomerID = " & Request.Form("TheInput")
something like that, i'm sorry i'm not at my computer to test it. someone will correct me if i'm wrong though :)
 
Thanks for your response. I tried this, but get the following error:

Error Type:
Microsoft JET Database Engine (0x80040E10)
No value given for one or more required parameters.

My line read as follows:

"SELECT * FROM CUSTOMERS WHERE CUSTOMERID ="&Request.Form("searchtext")
 
Perfect! I had left out the '. Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top