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

Access DB Where Statement

Status
Not open for further replies.

racherry

MIS
Oct 6, 2002
31
0
0
US
There may be a better place to post this question but here goes. Access DB with a table called tblUser.
I collect from a form a idUser, the Primary key of the table;
dim id, stmt, rs
id = Request.QueryString("id")
Stmt = "Select idUser, IMail, Exch, Notes From tblUser where idUser=" & id
rs.open stmt, cn
The error is:
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

Usually to me this means I have a field name misspelled.... not the case.

In fact if I run the query with only idUser without the 'Where idUser=" & id' and display all the records, it works great. For some reason it does not like the idUser in the Where.

Can anyone tell me why?
 
I think the problem is that the SQL engine requires string variables to be enclosed with single quotes i.e.

Stmt = "Select idUser, IMail, Exch, Notes From tblUser where idUser=" & "'" & id & "'"

This assumes that the column idUser is of type text within the access database.

Hope this helps.
 
On the money.... usually I'm passing id as an integer, this is text. Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top