|
-
Feb 7th, 2005, 07:00 PM
#1
Thread Starter
Member
SQL Update command
I am trying to do an update of a database record but i keep getting an error message saying " datatype mismatch in criteria expression". I have checked my datatypes in database against my variable datatypes and things match up, but still get the error.
Table Columns
ProductID - Autonumber - long id - long
PRODUCTNAME - text prodname - string
DESCRIPTION - text proddesc - string
Price - currency price - currency
quantity - integer qty - integer
category - text cat - text
image - text prodimage - string
The left is the database columns and datatypes, to the right are the variable names and datatypes. I can't see how there could be a mismatch???
Below is the code using for the SQL command:
Set ors = New ADODB.Recordset
ors.LockType = adLockOptimistic
SQL = "UPDATE tblProducts "
SQL = SQL & "SET PRODUCTNAME = '" & prodname & "', DESCRIPTION = '" & proddesc & "', CATEGORY='" & cat & "', PRICE= '" & price & "', QUANTITY='" & qty & "' "
SQL = SQL & "WHERE PRODUCTID = '" & id & "'"
Text1.Text = SQL
Set ors = oConn.Execute(SQL).
this should work(i think), but doesn't. I can't seem to find any error in the SQL statement. Can someone help me out again here. Thanks again in advance.
oobern
Last edited by oobern; Feb 8th, 2005 at 03:53 PM.
Reason: RESOLVED
-
Feb 7th, 2005, 08:27 PM
#2
Re: SQL Update command
Do not use a RS variable with an UPDATE clause - in an EXECUTE.
I would personnally create a COMMAND object, and then EXECUTE that.
I'm not at the office right now so I cannot give you any code snippets - try the online help.
-
Feb 7th, 2005, 11:56 PM
#3
Re: SQL Update command
Use objconn.Execute, and if Quantity and ID are numeric fields, remove the single quotes from around them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|