Skip to main content
Participant
January 16, 2009
Question

Error while updating a record in MS Access

  • January 16, 2009
  • 1 reply
  • 615 views
Im new to coldfusion and am running into a problem while trying to update a record in a MS Access table.

I have a MS Access table where the primary key is a auto-number long integer field named jobid.

I have an edit form where info can be changed then saved. A hidden form field named jobid holds the records primary key field value for the record being edited. When submitted this is what happens:

I use a basic SQL UPDATE statement but I get the error "Data type mismatch in criteria expression"

Some code:

<cfset nJobId=Int(Val(FORM.jobid))>
*dont know if i need the above line but using #FORM.jobid# in the WHERE clause below didnt work either

<cfquery datasource="lrs">
UPDATE jobs SET
status='#FORM.status#',
offer='#FORM.offer#',
postdate="#CreateODBCDate(FORM.postdate)#",
jobtype=#FORM.jobtype#,
jobtitle='#FORM.jobtitle#',
..etc...
WHERE jobid=#nJobId#

The WHERE clause is where the error occurs with "Data type mismatch in criteria expression"

After a few times with that i changed the where clause to simply "WHERE jobid=1" as this record id does exist, but it has the same error.

I then tried changing the where clause to
WHERE jobid=<cfqueryparam cfsqltype="cf_sql_bigint" value="#FORM.jobid#">

and there it "appears" to work, but the record is not actually updated. No changes are made to the table though no error is thrown.

Im missing something here... why wont the record update ?
This topic has been closed for replies.

1 reply

Inspiring
January 16, 2009
The data type mismatch isn't necessarily in your where clause. I'm guessing that it's the quotes around the create odbcdate function.

use of cfqueryparam will solve a lot of these problems for you.