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

Simple problem with query in recordset 2

Status
Not open for further replies.

sbayter

IS-IT--Management
Nov 14, 2002
95
CO
Hi,
i'm trying to create a page were users can go and upload their information.
This is my recordset:

<%
Dim myRs
Dim myRs_numRows

Set myRs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
myRs.ActiveConnection = MM_myConn_STRING
myRs.Source = &quot;SELECT * FROM users WHERE ID= '&quot;&varUserID&&quot;' &quot;
myRs.CursorType = 0
myRs.CursorLocation = 2
myRs.LockType = 1
myRs.Open()

myRs_numRows = 0
%>

varUserID has the value 1 for the test user.

This is the error:
Data type mismatch in criteria expression.
/bn/myprofile.asp, line 135

line 35 is myRs.Open()

Somehow if I change the query to be (...WHERE ID= 1 &quot;) it works perfect.
What am I doing wrong?
Thanks,



sbayter
 
if the ID is a number, then take away the '' in the select statement so it will look like this:
SELECT * FROM users WHERE ID= &quot;&varUserID
which is equal to:
SELECT * FROM users WHERE ID= 1
which works, of course 1 is just an example for any number.
 
that worked!
thanks!

sbayter
 
hello

Using this:
myRs.Source = &quot;SELECT * FROM users WHERE ID= '&quot; & varUserID & &quot;'&quot;

Only when ID is a string, use the '

If it's a number don't use that





Follow the dark side, so you can reach the light.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top