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

SQL data mismatch error

Status
Not open for further replies.

ozpeppers

Programmer
Jul 17, 2001
32
BN
Hi

I'm executing an sql statement and get an error msg - "data mismatch in criteria expression" pointing to the RS.Open line

//code

mySQL = "SELECT * FROM room WHERE [roomTypeID]like'" & myRoomTypeID & "' AND roomMaxPeople >='" & myRoomMaxStu & "' ORDER BY roomMaxPeople;"

Conn.Open
RS.Open mySQL, Conn, adOpenDynamic, adLockOptimistic, adCmdUnknown

// end of code

In the access 97 database:

"roomMaxPeople" is an long integer number

The variable "myRoomMaxStu" is an set as integer

any ideas?

cheers in advance mark
 
mySQL = "SELECT * FROM room WHERE [roomTypeID]like" & myRoomTypeID & " AND roomMaxPeople >=" & myRoomMaxStu & " ORDER BY roomMaxPeople;"

Chaz



 
Rats, second attempt

mySQL = "SELECT * FROM room WHERE [roomTypeID]like " & myRoomTypeID & " AND roomMaxPeople >= " & myRoomMaxStu & " ORDER BY roomMaxPeople;"

Forgot some spaces

Chaz

 
You are passing you variables as strings. If myRoomMaxStu is an integer then lose the single quotes('):

mySQL = "SELECT * FROM room WHERE [roomTypeID]like" & myRoomTypeID & " AND roomMaxPeople >=" & myRoomMaxStu & " ORDER BY roomMaxPeople;"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top