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

Data Type mismatch

Status
Not open for further replies.

dodge20

MIS
Joined
Jan 15, 2003
Messages
1,048
Location
US
I keep getting a datatype mismatch when I try to run this query. It is when I try to use the = with the variable. College name is a list/menu on my form, and idnumber is an autonumber in the database. Can someone help me out?

SELECT iname, college_name, idnumber
FROM college, student
WHERE college.ipassword = student.ipassword and (isort like '%varlast_name%' or college_name = 'varcollege' or idnumber = 'varidnumber')

varlast_name % Request("isort")
varcollege % Request("college_name")
varidnumber % Request("idnumber")

Dodge20
 
Try removing the single quotes from around varidnumber in your WHERE statement.
 
Without the quotes, I get a syntax error.

I am curious if I don't want a % for the default when I use an =. If not, what would I use?

Dodge20
 
sql = "SELECT iname, college_name, idnumber
FROM college, student
WHERE college.ipassword = student.ipassword and (isort like '%" & varlast_name& "%' or college_name = '" & varcollege & "' or idnumber = '" & varidnumber & "')"

Cheech

[Peace][Pipe]
 
That gave me a data type mismatch also. What I ended up doing is changing the or's to and's and using like instead of the equal sign. I don't understand the syntax with the quotes and &'s.

Dodge20
 
Dodge- where are you entering this SQL statement? Are you in "Code View" directly editing an asp script or is this from a wizard?
 
I am entering it as a record set on the server behaviors. I am not doing it in code view.

Dodge20
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top