I have been having trouble with getting this record to post
to my DB, I have the same form set up to edit an existing record,
as well as adding a new record. I get 2 errors, Can anyone help me
see what I am doing wrong? I am posting the code I am having
trouble with, and both errors. I am sorry, it is probably simple.
But I have been looking at this code too long and am missing the
problem.
The Code:
%26lt;cfelseif ParameterExists(Form.btnEdit_OK)%26gt;
%26lt;cfif ParameterExists(Form.RecordID)%26gt;
%26lt;cfset eDate = DateFormat(form.eventDate,
''mm/dd/yyyy'')%26gt;
%26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#'' dbtype=''ODBC''%26gt;
UPDATE SEEevents
SET SEEevents.display='#form.display#',
SEEevents.title='#form.title#', SEEevents.eventDate='#eDate#',
SEEevents.eventTime='#form.eventTime#',
SEEevents.location='#form.location#',
SEEevents.contact='#form.contact#', SEEevents.phone='#form.phone#',
SEEevents.fax='#form.fax#', SEEevents.email='#form.email#',
SEEevents.URL='#form.URL#', SEEevents.sponsor='#form.sponsor#',
SEEevents.Body='#form.PDSeditor#'
WHERE RecordID = #form.RecordID#
%26lt;/cfquery%26gt;
%26lt;cflocation
url=''events_RecordView.cfm?RecordID=#Form.RecordID#''%26gt;
%26lt;cfelse%26gt;
%26lt;cfset eDate = DateFormat(form.eventDate,
''mm/dd/yyyy'')%26gt;
%26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#'' dbtype=''ODBC''%26gt;
INSERT INTO SEEevents (display, title, eventDate, eventTime,
location, contact, phone, fax, email, URL, sponsor, Body)
VALUES ('#form.display#', '#form.title#', '###eDate###',
'#form.eventTime#', '#form.location#', '#form.contact#',
'#form.phone#', '#form.fax#', '#form.email#', '#form.URL#',
'#form.sponsor#', '#form.PDSeditor#')
%26lt;/cfquery%26gt;
%26lt;cflocation
url=''events_RecordView.cfm?RecordID=#GetNewRecord.ID_Field#''%26gt;
%26lt;/cfif%26gt;
Here are both errors:
error when editing an existing record:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Too few
parameters. Expected 1.
The error occurred in
C:\websites\108392zj7\admin\events_RecordAction.cfm: line 70
68 : %26lt;cfif ParameterExists(Form.RecordID)%26gt;
69 : %26lt;cfset eDate = DateFormat(form.eventDate,
''mm/dd/yyyy'')%26gt;
70 : %26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#'' dbtype=''ODBC''%26gt;
71 : UPDATE SEEevents
72 : SET SEEevents.display='#form.display#',
SEEevents.title='#form.title#', SEEevents.eventDate='#eDate#',
SEEevents.eventTime='#form.eventTime#',
SEEevents.location='#form.location#',
SEEevents.contact='#form.contact#', SEEevents.phone='#form.phone#',
SEEevents.fax='#form.fax#', SEEevents.email='#form.email#',
SEEevents.URL='#form.URL#', SEEevents.sponsor='#form.sponsor#',
SEEevents.Body='#form.PDSeditor#'
--------------------------------------------------------------------------------
SQL UPDATE SEEevents SET SEEevents.display='0',
SEEevents.title='VIP Dinner', SEEevents.eventDate='04/13/2007',
SEEevents.eventTime='8:30pm - 11:00pm', SEEevents.location='person
Restaurant', SEEevents.contact='person', SEEevents.phone='(000)
000.6262', SEEevents.fax='', SEEevents.email='mail@person.com',
SEEevents.URL='
http://www.person.com',
SEEevents.sponsor='', SEEevents.Body=' %26lt;font size=''2''
face=''Verdana, Arial, Helvetica,
sans-serif''%26gt;%26lt;strong%26gt;Notes:%26lt;/strong%26gt; Reservations
must be confirmed with a major credit
card.%26lt;br%26gt;%26lt;strong%26gt;Price:%26lt;/strong%26gt; Advance: $125.
per person (includes gratuity and cocktail hour) At the door: $150.
per person %26lt;i%26gt; Limited seating
available%26lt;/i%26gt;%26lt;/font%26gt; ' WHERE RecordID = 13
DATASOURCE csee
VENDORERRORCODE -3010
SQLSTATE 07002
This is the error when posting a new record:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Data type mismatch
in criteria expression.
The error occurred in
C:\websites\108392zj7\admin\events_RecordAction.cfm: line 78
76 : %26lt;cfelse%26gt;
77 : %26lt;cfset eDate = DateFormat(form.eventDate,
''mm/dd/yyyy'')%26gt;
78 : %26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#'' dbtype=''ODBC''%26gt;
79 : INSERT INTO SEEevents (display, title, eventDate,
eventTime, location, contact, phone, fax, email, URL, sponsor,
Body)
80 : VALUES ('#form.display#', '#form.title#', '###eDate###',
'#form.eventTime#', '#form.location#', '#form.contact#',
'#form.phone#', '#form.fax#', '#form.email#', '#form.URL#',
'#form.sponsor#', '#form.PDSeditor#')
--------------------------------------------------------------------------------
SQL INSERT INTO SEEevents (display, title, eventDate,
eventTime, location, contact, phone, fax, email, URL, sponsor,
Body) VALUES ('0', 'Testing', '#03/25/2007#', '12:47', 'Home',
'MJC', '000-000-0000', '', 'me@saratogaexpo.com',
'www.saratogaexpo.com', 'all of us', ' ')
DATASOURCE csee
VENDORERRORCODE -3030
SQLSTATE 22018
Can anyone help me tweek this code? I am seeing double at
this point. Thank you.
Phoenix
Error Executing Database Query; Please...
Why the triple ###'s around eDate? Notice it is attempting to
put #03/25/07# into a datetime field (at least I assume that's the
data type of the field you are inserting.
Let me know if that works.
I'm going to look at your update code right now.
- Mike
Error Executing Database Query; Please...
Why are you describing a dbtype of ''odbc'' in your cfquery
statement, by the way? That info is usually inferred within the
datasource setup in CF Admin. I could be wrong - does this work
successfully in other pages for you?
I never use dbtype if I have pointed to a datasource. Maybe
try that?
- Mike
In the UPDATE statement, all values are FORM scope except for
edate. Is that intended? The value for eventDate looks a little
wierd in your UPDATE and INSERT statements. What is the data type
in the database?
Yes it is date/time In the field of the db. I took out the 3
### around the eDate in the query, it still didn't accept it.
Is there a way to rewrite this statement and make it work
better? here is the error I get now from trying to update an
existing record:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Too few
parameters. Expected 1.
The error occurred in
C:\websites\108392zj7\admin\events_RecordAction.cfm: line 70
68 : %26lt;cfif ParameterExists(Form.RecordID)%26gt;
69 : %26lt;cfset eDate = DateFormat(form.eventDate,
''mm/dd/yyyy'')%26gt;
70 : %26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#''%26gt;
71 : UPDATE SEEevents
72 : SET SEEevents.display='#form.display#',
SEEevents.title='#form.title#', SEEevents.eventDate='#eDate#',
SEEevents.eventTime='#form.eventTime#',
SEEevents.location='#form.location#',
SEEevents.contact='#form.contact#', SEEevents.phone='#form.phone#',
SEEevents.fax='#form.fax#', SEEevents.email='#form.email#',
SEEevents.URL='#form.URL#', SEEevents.sponsor='#form.sponsor#',
SEEevents.Body='#form.PDSeditor#'
--------------------------------------------------------------------------------
SQL UPDATE SEEevents SET SEEevents.display='0',
SEEevents.title='VIP Dinner', SEEevents.eventDate='04/13/2007',
SEEevents.eventTime='8:30pm - 11:00pm', SEEevents.location='person
Restaurant', SEEevents.contact='someplace', SEEevents.phone='(000)
000.6262', SEEevents.fax='', SEEevents.email='mail@person.com',
SEEevents.URL='
http://www.person.com',
SEEevents.sponsor='', SEEevents.Body=' %26lt;font size=''2''
face=''Verdana, Arial, Helvetica,
sans-serif''%26gt;%26lt;strong%26gt;Notes:%26lt;/strong%26gt; Reservations
must be confirmed with a major credit
card.%26lt;br%26gt;%26lt;strong%26gt;Price:%26lt;/strong%26gt; Advance: $125.
per person (includes gratuity and cocktail hour) At the door: $150.
per person %26lt;i%26gt; Limited seating
available%26lt;/i%26gt;%26lt;/font%26gt; ' WHERE RecordID = 13
DATASOURCE csee
VENDORERRORCODE -3010
SQLSTATE 07002
Again, been looking at this code too long. Thank you for the
help
Phoenix
Well, it looks like my advice on removeing the dbtype=ODBC
statement was wrong.
I didn't mean take all 3 out, :-), just keep it as '#eDate#',
since at this point it is a variable you set earlier.
Also, I might suggest posting this under the Database Forum,
I saw Dan Bracuk and several others around, they are much sharper
than me.
- Mike
You're
sure that eDate is not FORM scoped? eTime is.
ok, I will go to the DB forum. Thank you for your help.
Phoenix
Whoa! jdeline is responding - you're in luck.
Don't go anywhere just quite yet!
Someone made that cfset for me and were trying to use it. The
DB is an access DB and that spot in the table is set to accept
date/time. If there is a better way to write this expression, I am
all ears... and eyes.
Phoenix
I wanted to add, I also tried these other codes:
I changed SEEevents.eventDate='###eDate###' to:
SEEevents.eventDate=%26lt;cfqueryparam type='' CF_SQL_TIMESTAMP''
value=''#form.eventDate#''%26gt;
and
SEEevents.eventDate=%26lt;cfqueryparam type='' CF_SQL_DATE''
value=''#form.eventDate#''%26gt;
and
SEEevents.eventDate=#CREATEODBCDATE(form.eventDate)#
Now with the code:
SEEevents.eventDate=#CREATEODBCDATE(form.eventDate)#
this is the error I get:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error
(missing operator) in query expression ''{d '2007-04-13'}''.
The error occurred in
C:\websites\108392zj7\admin\events_RecordAction.cfm: line 69
67 :
68 : %26lt;cfif ParameterExists(Form.RecordID)%26gt;
69 : %26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#'' dbtype=''ODBC''%26gt;
70 : UPDATE SEEevents
71 : SET SEEevents.display='#form.display#',
SEEevents.title='#form.title#',
SEEevents.eventDate='#CREATEODBCDATE(form.eventDate)#',
SEEevents.eventTime='#form.eventTime#',
SEEevents.location='#form.location#',
SEEevents.contact='#form.contact#', SEEevents.phone='#form.phone#',
SEEevents.fax='#form.fax#', SEEevents.email='#form.email#',
SEEevents.URL='#form.URL#', SEEevents.sponsor='#form.sponsor#',
SEEevents.Body='#form.PDSeditor#'
--------------------------------------------------------------------------------
SQL UPDATE SEEevents SET SEEevents.display='0',
SEEevents.title='VIP Dinner', SEEevents.eventDate='{d
'2007-04-13'}', SEEevents.eventTime='8:30pm - 11:00pm',
SEEevents.location='person Restaurant',
SEEevents.contact='person''s', SEEevents.phone='(000) 000.6262',
SEEevents.fax='', SEEevents.email='mail@person.com',
SEEevents.URL='
http://www.person.com',
SEEevents.sponsor='', SEEevents.Body=' %26lt;font size=''2''
face=''Verdana, Arial, Helvetica,
sans-serif''%26gt;%26lt;strong%26gt;Notes:%26lt;/strong%26gt; Reservations
must be confirmed with a major credit
card.%26lt;br%26gt;%26lt;strong%26gt;Price:%26lt;/strong%26gt; Advance: $125.
per person (includes gratuity and cocktail hour) At the door: $150.
per person %26lt;i%26gt; Limited seating
available%26lt;/i%26gt;%26lt;/font%26gt; ' WHERE RecordID = 13
DATASOURCE csee
VENDORERRORCODE -3100
SQLSTATE 42000
What the hack am I missing?
I am kind of new to this adding time/date to a db.
Anyone have a solution that might work. I need to get this
fixed today so records can be modified. Sorry for teh persistance.
Phoenix
I wanted to add, I also tried these other codes:
I changed SEEevents.eventDate='###eDate###' to:
SEEevents.eventDate=%26lt;cfqueryparam type='' CF_SQL_TIMESTAMP''
value=''#form.eventDate#''%26gt;
and
SEEevents.eventDate=%26lt;cfqueryparam type='' CF_SQL_DATE''
value=''#form.eventDate#''%26gt;
and
SEEevents.eventDate=#CREATEODBCDATE(form.eventDate)#
Now with the code:
SEEevents.eventDate=#CREATEODBCDATE(form.eventDate)#
this is the error I get:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error
(missing operator) in query expression ''{d '2007-04-13'}''.
The error occurred in
C:\websites\108392zj7\admin\events_RecordAction.cfm: line 69
67 :
68 : %26lt;cfif ParameterExists(Form.RecordID)%26gt;
69 : %26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#'' dbtype=''ODBC''%26gt;
70 : UPDATE SEEevents
71 : SET SEEevents.display='#form.display#',
SEEevents.title='#form.title#',
SEEevents.eventDate='#CREATEODBCDATE(form.eventDate)#',
SEEevents.eventTime='#form.eventTime#',
SEEevents.location='#form.location#',
SEEevents.contact='#form.contact#', SEEevents.phone='#form.phone#',
SEEevents.fax='#form.fax#', SEEevents.email='#form.email#',
SEEevents.URL='#form.URL#', SEEevents.sponsor='#form.sponsor#',
SEEevents.Body='#form.PDSeditor#'
--------------------------------------------------------------------------------
SQL UPDATE SEEevents SET SEEevents.display='0',
SEEevents.title='VIP Dinner', SEEevents.eventDate='{d
'2007-04-13'}', SEEevents.eventTime='8:30pm - 11:00pm',
SEEevents.location='person Restaurant',
SEEevents.contact='person''s', SEEevents.phone='(000) 000.6262',
SEEevents.fax='', SEEevents.email='mail@person.com',
SEEevents.URL='
http://www.person.com',
SEEevents.sponsor='', SEEevents.Body=' %26lt;font size=''2''
face=''Verdana, Arial, Helvetica,
sans-serif''%26gt;%26lt;strong%26gt;Notes:%26lt;/strong%26gt; Reservations
must be confirmed with a major credit
card.%26lt;br%26gt;%26lt;strong%26gt;Price:%26lt;/strong%26gt; Advance: $125.
per person (includes gratuity and cocktail hour) At the door: $150.
per person %26lt;i%26gt; Limited seating
available%26lt;/i%26gt;%26lt;/font%26gt; ' WHERE RecordID = 13
DATASOURCE csee
VENDORERRORCODE -3100
SQLSTATE 42000
What the hack am I missing?
I am kind of new to this adding time/date to a db.
Anyone have a solution that might work. I need to get this
fixed today so records can be modified. Sorry for the persistance.
Phoenix
Phoenix,
I'll just post what it is that I do in this situation, and
maybe your can ''translate it'', since there are a few differences,
primarily that I use SQL. (Windows 2003 Server, IIS, CF MX 6.1).
For date/time ''stuff'':
%26lt;cfset todaysdate = #DateFormat(Now(),''mm/dd/yy'')#%26gt;
OR to have the time with it
%26lt;cfset todaystime = #DateFormat(Now())# %26amp; '' '' %26amp;
#TimeFormat(Now())#%26gt;
The above I use to set the default for the field on the form
that correspond, to say ''Field1'' and ''Field2''.
Then, I use ''cfupdate'' to do my updates, although I will
mention that Dan Bracuk, one of the VERY senior members, recommends
your method.
If, of course, I use cfupdate, I have to include my keyfield
first, and do this:
%26lt;cfif IsDefined(''Form.myvariable'') AND Form.myvariable GT
whatevernumberorcriteria%26gt;
%26lt;cfupdate datasource=''mydatasource'' tablename=''mytable''
formfields=''MyPrimaryKey,Field1,Field2''%26gt;
%26lt;/cfif%26gt;
Anyway, give it a translation try, and I will try to keep
checking to see how it's going.
- Mike
Phoenix,
I will re-check posts after 7:30pm. Hope all is well!
- Mike
Ok, I tried it with all the ways you posted. Still getting a
missing operator error. (why is this such a pain?)
Here is my error:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error
(missing operator) in query expression ''{d '2007-04-13'}''.
The error occurred in
C:\websites\108392zj7\admin\events_RecordAction.cfm: line 70
68 : %26lt;cfif ParameterExists(Form.RecordID)%26gt;
69 : %26lt;cfset EventDate = #DateFormat(Now(),''mm/dd/yy'')#%26gt;
70 : %26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#'' dbtype=''ODBC''%26gt;
71 : UPDATE SEEevents
72 : SET SEEevents.display='#form.display#',
SEEevents.title='#form.title#',
SEEevents.eventDate='#CREATEODBCDATE(form.eventDate)#',
SEEevents.eventTime='#form.eventTime#',
SEEevents.location='#form.location#',
SEEevents.contact='#form.contact#', SEEevents.phone='#form.phone#',
SEEevents.fax='#form.fax#', SEEevents.email='#form.email#',
SEEevents.URL='#form.URL#', SEEevents.sponsor='#form.sponsor#',
SEEevents.Body='#form.PDSeditor#'
--------------------------------------------------------------------------------
SQL UPDATE SEEevents SET SEEevents.display='0',
SEEevents.title='VIP Dinner', SEEevents.eventDate='{d
'2007-04-13'}', SEEevents.eventTime='8:30pm - 11:00pm',
SEEevents.location='Brindisi''s Restaurant',
SEEevents.contact='Brindisi''s', SEEevents.phone='(518) 587.6262',
SEEevents.fax='', SEEevents.email='mail@brindisis.com',
SEEevents.URL='
http://www.brindisis.com',
SEEevents.sponsor='', SEEevents.Body=' %26lt;font size=''2''
face=''Verdana, Arial, Helvetica,
sans-serif''%26gt;%26lt;strong%26gt;Notes:%26lt;/strong%26gt; Reservations
must be confirmed with a major credit
card.%26lt;br%26gt;%26lt;strong%26gt;Price:%26lt;/strong%26gt; Advance: $125.
per person (includes gratuity and cocktail hour) At the door: $150.
per person %26lt;i%26gt; Limited seating
available%26lt;/i%26gt;%26lt;/font%26gt; ' WHERE RecordID = 13
DATASOURCE csee
VENDORERRORCODE -3100
SQLSTATE 42000
Resources:
This is the code I am using now:
%26lt;cfelseif ParameterExists(Form.btnEdit_OK)%26gt;
%26lt;cfif ParameterExists(Form.RecordID)%26gt;
%26lt;cfset eventDate = #DateFormat(Now(),''mm/dd/yy'')#%26gt;
%26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#'' dbtype=''ODBC''%26gt;
UPDATE SEEevents
SET SEEevents.display='#form.display#',
SEEevents.title='#form.title#',
SEEevents.eventDate='#CREATEODBCDATE(form.eventDate)#',
SEEevents.eventTime='#form.eventTime#',
SEEevents.location='#form.location#',
SEEevents.contact='#form.contact#', SEEevents.phone='#form.phone#',
SEEevents.fax='#form.fax#', SEEevents.email='#form.email#',
SEEevents.URL='#form.URL#', SEEevents.sponsor='#form.sponsor#',
SEEevents.Body='#form.PDSeditor#'
WHERE RecordID = #form.RecordID#
%26lt;/cfquery%26gt;
%26lt;cflocation
url=''events_RecordView.cfm?RecordID=#Form.RecordID#''%26gt;
%26lt;cfelse%26gt;
%26lt;cfset eDate = DateFormat(form.eventDate,
''mm/dd/yyyy'')%26gt;
%26lt;cfquery datasource=''#sitedatasource#''
username=''#siteUserID#'' password=''#sitePassword#'' dbtype=''ODBC''%26gt;
INSERT INTO SEEevents (display, title, eventDate, eventTime,
location, contact, phone, fax, email, URL, sponsor, Body)
VALUES ('#form.display#', '#form.title#', '#eDate#',
'#form.eventTime#', '#form.location#', '#form.contact#',
'#form.phone#', '#form.fax#', '#form.email#', '#form.URL#',
'#form.sponsor#', '#form.PDSeditor#')
%26lt;/cfquery%26gt;
%26lt;cflocation
url=''events_RecordView.cfm?RecordID=#GetNewRecord.ID_Field#''%26gt;
%26lt;/cfif%26gt;
I tried the 2 types of cfset:
%26lt;cfset todaysdate = #DateFormat(Now(),''mm/dd/yy'')#%26gt;
and now I have it as:
%26lt;cfset eventDate = #DateFormat(Now(),''mm/dd/yy'')#%26gt;
Neither way is working. I am totally confused at this point.
Phoenix