OccasionalCoder
Technical User
I get a datatype mismatch error when I use the following update code:
<cfquery datasource="#db#" username="#un#" password="#pw#">
update copyfellows
set
first_name='#trim(form.first_name)#',
mi='#trim(form.mi)#',
last_name='#trim(form.last_name)#',
suffix='#trim(form.suffix)#',
nee='#trim(form.nee)#',
photo='#trim(form.photo)#',
agency='#trim(form.agency)#',
abbr='#trim(form.abbr)#',
division='#trim(form.division)#',
unit='#trim(form.unit)#',
school='#trim(form.school)#',
program='#trim(form.program)#',
synopsis='#trim(form.synopsis)#',
website='#trim(form.website)#',
email='#trim(form.email)#',
<cfif len(trim(form.start_year)) is 0>start_year=null,
<cfelse>
start_year='#trim(form.start_year)#',
</cfif>
<cfif len(trim(form.end_year)) is 0>end_year=null,
<cfelse>
end_year='#trim(form.end_year)#',
</cfif>
<cfif len(trim(form.twostart_year)) is 0>twostart_year=null,
<cfelse>
twostart_year='#trim(form.twostart_year)#',
</cfif>
<cfif len(trim(form.twoend_year)) is 0>twoend_year=null,
<cfelse>
twoend_year='#trim(form.twoend_year)#',
</cfif>
status='#form.status#'
where entry_id=#form.entry_id#
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<cfoutput>
#first_name# #mi# #last_name# has been updated.<br><br>
</cfoutput>
<a href="edit1.cfm">Edit another entry?</a>
<a href="../mainmenu.cfm">Main Menu</a>
</body>
</html>
------------
This is the error:
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
The error occurred in C:\Inetpub\ line 41
39 :
40 : status='#form.status#'
41 : where entry_id=#form.entry_id#
42 : </cfquery>
43 :
----------
I've been looking at the code for a couple of hours and cannot see the reason for the error. Is there something about using null's with date/time datatypes that's not obvious?
Thanks for the help.
<cfquery datasource="#db#" username="#un#" password="#pw#">
update copyfellows
set
first_name='#trim(form.first_name)#',
mi='#trim(form.mi)#',
last_name='#trim(form.last_name)#',
suffix='#trim(form.suffix)#',
nee='#trim(form.nee)#',
photo='#trim(form.photo)#',
agency='#trim(form.agency)#',
abbr='#trim(form.abbr)#',
division='#trim(form.division)#',
unit='#trim(form.unit)#',
school='#trim(form.school)#',
program='#trim(form.program)#',
synopsis='#trim(form.synopsis)#',
website='#trim(form.website)#',
email='#trim(form.email)#',
<cfif len(trim(form.start_year)) is 0>start_year=null,
<cfelse>
start_year='#trim(form.start_year)#',
</cfif>
<cfif len(trim(form.end_year)) is 0>end_year=null,
<cfelse>
end_year='#trim(form.end_year)#',
</cfif>
<cfif len(trim(form.twostart_year)) is 0>twostart_year=null,
<cfelse>
twostart_year='#trim(form.twostart_year)#',
</cfif>
<cfif len(trim(form.twoend_year)) is 0>twoend_year=null,
<cfelse>
twoend_year='#trim(form.twoend_year)#',
</cfif>
status='#form.status#'
where entry_id=#form.entry_id#
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<cfoutput>
#first_name# #mi# #last_name# has been updated.<br><br>
</cfoutput>
<a href="edit1.cfm">Edit another entry?</a>
<a href="../mainmenu.cfm">Main Menu</a>
</body>
</html>
------------
This is the error:
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
The error occurred in C:\Inetpub\ line 41
39 :
40 : status='#form.status#'
41 : where entry_id=#form.entry_id#
42 : </cfquery>
43 :
----------
I've been looking at the code for a couple of hours and cannot see the reason for the error. Is there something about using null's with date/time datatypes that's not obvious?
Thanks for the help.