Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Data type mismatch in criteria expression.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-11-11 : 10:35:31
Hemal writes "I have a table in an Access database where the primary key is a field called ID and it is of data type Long Integer. I'm using ASP when I query the database. When someone logs into the system I store their ID in a variable called Session("ID"). I have a page where they can change their password. I used the SQL expression:

"UPDATE Customers SET Password='" & Request.Form("newpassword") & "' WHERE ID='" & Session("ID") & "';"

When the expression is executed I get this error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

I knew the data type mismatch was with the ID so I declared a variable called UserID. Then I used the expression:

UserID = CLng(Session("ID"))

That should convert it to a long integer. Then I used the SQL expression:

"UPDATE Customers SET Password='" & Request.Form("newpassword") & "' WHERE ID='" & UserID & "';"

When that expression was executed I got the same error as before. I am stumped. How do I get it so that the data types match? Thanks.

Hemal Desai"

mr_mist
Grunnio

1870 Posts

Posted - 2002-11-11 : 11:05:59
quote:

Hemal writes "I have a table in an Access database where the primary key is a field called ID and it is of data type Long Integer. I'm using ASP when I query the database. When someone logs into the system I store their ID in a variable called Session("ID"). I have a page where they can change their password. I used the SQL expression:

"UPDATE Customers SET Password='" & Request.Form("newpassword") & "' WHERE ID='" & Session("ID") & "';"

When the expression is executed I get this error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e07'
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.

I knew the data type mismatch was with the ID so I declared a variable called UserID. Then I used the expression:

UserID = CLng(Session("ID"))

That should convert it to a long integer. Then I used the SQL expression:

"UPDATE Customers SET Password='" & Request.Form("newpassword") & "' WHERE ID='" & UserID & "';"

When that expression was executed I got the same error as before. I am stumped. How do I get it so that the data types match? Thanks.

Hemal Desai"



Your're passing ID in quotes. I've not used access in this manner but maybe you need to pass it a number, without quotes. Other than that I would check to see if it is complaining because your column is called ID or password.

P.S. I would also advise against updating directly from the results of the request.form. You should at the very least be doing some rudimentaty error checking.



Edited by - mr_mist on 11/11/2002 11:10:35
Go to Top of Page
   

- Advertisement -