Ask a Question related to Coldfusion Database Access, Design and Development.
-
stillwaiting #1
Error that I can't figure out
----------------------------------------------------------------
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC
Microsoft Access Driver] Syntax error in INSERT INTO statement.
The error occurred in C:\CFusionMX\wwwroot\Test\update.cfm: line 67
65 : <cfelse>
66 : NULL
67 : </cfif>
68 : )
69 : </cfquery>
SQL INSERT INTO Legal Issues (title, link,"date") VALUES ( 'test' ,
'www.test.com' , #5/20/05# )
DATASOURCE sp2
VENDORERRORCODE -3502
SQLSTATE 42000
---------------------------------------------------------------
The entire code statement that the error occured in is as follows:
---------------------------------------------------------------
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
"lgl_issues">
<cfquery datasource="sp2" password="************">
INSERT INTO Legal Issues (title, link,"date") VALUES (
<cfif IsDefined("FORM.title") AND #FORM.title# NEQ "">
'#FORM.title#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.link") AND #FORM.link# NEQ "">
'#FORM.link#'
<cfelse>
NULL
</cfif>
,
<cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">
###FORM.date###
<cfelse>
NULL
</cfif> <----This is line 67
)
</cfquery>
</cfif>
------------------------------------------------------------
I have another query above it that was put together the exact same way
with DW and it operates correctly but this one and the 4 more following
don't work. Any thoughts?
stillwaiting
stillwaiting Guest
-
Help Error I cannot figure out !!!
Hi, I am wondering if anyone knows how to fix this issue. I suddenly get an error "Access Denied. The file may not exist or there could be a... -
Invalid object name Error I can't figure Out
This is the error I'm recieving: Error Executing Database Query. Invalid object name 'f_users'. The error occurred in... -
I can't figure it out! (CDO.Message.1 error '80070005' )
I'm at my wits end! There are a ton of people out there that are receiving the following error: "CDO.Message.1 error '80070005'" and a number of... -
Databind Error -- cannot figure out why.
I get the following error on Line 49 (UG1.DataBind()) only if the Select Stored procedure returns no records. I am using a dataadapter and a... -
How do you figure out the LDAP://? ("Error authenticating. Error authenticating user. The specified domain either does not exist or could not be contacted")
Hi, I am using the example "Authenticate against the Active Directory by Using Forms Authentication and Visual Basic .NET": ... -
The ScareCrow #2
Re: Error that I can't figure out
The error is related to the way you are passing the date, should be
#CreateODBCDate(form.date)#
Ken
The ScareCrow Guest
-
stillwaiting #3
Re: Error that I can't figure out
The ScareCrow wrote:
Your going to have to elaborate a little more. Why does my code work for> The error is related to the way you are passing the date, should be
> #CreateODBCDate(form.date)#
>
> Ken
the first form but not for the other ones? Where am I supposed to put
the above code? I tried putting your code in place of "#FORM.date# but
it returned the same error. I'm new at this and I'm afraid I need a
little more explanation.
<cfif IsDefined("FORM.date") AND #FORM.date# NEQ "">
###FORM.date###
<cfelse>
NULL
</cfif>
Thanks for the help so far,
stillwaiting
stillwaiting Guest
-
The ScareCrow #4
Re: Error that I can't figure out
Why does my code work for the first form but not for the other ones?
I don't know as I have not seen all the code, but I would assume there is a
difference somewhere.
The attached code is what you need
Ken
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
"lgl_issues">
<cfquery datasource="sp2" password="************">
INSERT INTO Legal Issues (title, link,"date")
VALUES (
<cfif IsDefined("FORM.title") AND
Len(Trim(FORM.title))>'#FORM.title#'<cfelse>NULL</cfif>,
<cfif IsDefined("FORM.link") AND
Len(Trim(FORM.link))>'#FORM.link#'<cfelse>NULL</cfif>,
<cfif IsDefined("FORM.date") AND
IsDate(FORM.date)>#CreateODBCDate(FORM.date)#<cfel se>NULL</cfif>
)
</cfquery>
</cfif>
The ScareCrow Guest
-
JMGibson3 #5
Re: Error that I can't figure out
Have you tried [date] rather than "date" for your column name that's a keyword.
You probably also need [Legal Issues] for a table name since it has an
embedded space in it. Better yet, rename everything in both the DB and your
SQL, since for all I know, "link" may also be a keyword:
tblLegalIssues
fldTitle
fldLink
fldDate
JMGibson3 Guest
-
stillwaiting #6
Re: Error that I can't figure out
I'll give it a try. That sounds like it may do the trick.
ScareCrow, the code you gave me still didn't work.
stillwaiting
JMGibson3 wrote:> Have you tried [date] rather than "date" for your column name that's a keyword.
> You probably also need [Legal Issues] for a table name since it has an
> embedded space in it. Better yet, rename everything in both the DB and your
> SQL, since for all I know, "link" may also be a keyword:
>
> tblLegalIssues
> fldTitle
> fldLink
> fldDate
>
>stillwaiting Guest
-
The ScareCrow #7
Re: Error that I can't figure out
Damn, can't believe I missed the space in the table name.
JMGibson3 is correct and you should change the db, but the attached will also
work
Ken
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
"lgl_issues">
<cfquery datasource="sp2" password="************">
INSERT INTO [Legal Issues] ([title], [link],[date])
VALUES (
<cfif IsDefined("FORM.title") AND
Len(Trim(FORM.title))>'#FORM.title#'<cfelse>NULL</cfif>,
<cfif IsDefined("FORM.link") AND
Len(Trim(FORM.link))>'#FORM.link#'<cfelse>NULL</cfif>,
<cfif IsDefined("FORM.date") AND
IsDate(FORM.date)>#CreateODBCDate(FORM.date)#<cfel se>NULL</cfif>
)
</cfquery>
</cfif>
The ScareCrow Guest
-
stillwaiting #8
Re: Error that I can't figure out
The ScareCrow wrote:
How exactly does the #CreateODBCDate(FORM.date)# differ in function? I> Damn, can't believe I missed the space in the table name.
>
> JMGibson3 is correct and you should change the db, but the attached will also
> work
>
> Ken
>
> <cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ
> "lgl_issues">
> <cfquery datasource="sp2" password="************">
> INSERT INTO [Legal Issues] ([title], [link],[date])
> VALUES (
> <cfif IsDefined("FORM.title") AND
> Len(Trim(FORM.title))>'#FORM.title#'<cfelse>NULL</cfif>,
> <cfif IsDefined("FORM.link") AND
> Len(Trim(FORM.link))>'#FORM.link#'<cfelse>NULL</cfif>,
> <cfif IsDefined("FORM.date") AND
> IsDate(FORM.date)>#CreateODBCDate(FORM.date)#<cfel se>NULL</cfif>
> )
> </cfquery>
> </cfif>
>
would actually prefer to have the date and maybe even time added to the
DB automatically. Could someone point me in the right direction on
figuring out how to do that?
By the way, I renamed all the tables and columns in my DB and it works
flawlessly now. Thanks a ton guys. You guys on these forums are a life
saver for those of us that are learning.
stillwaiting
stillwaiting Guest
-
The ScareCrow #9
Re: Error that I can't figure out
createodbcdate passes an odbc date data type to the sql query, where as
#FORM.date# passes a string.
You should always keep dates as dates, the only time you should convert a date
value is to display it to a user.
To have the db automatically insert the current date/time in the column.
Open you ms access db
Click on the date/time column
In the bottom pane you will see the word "default value" in the space next to
this enter Now()
Also under this is also "required"
Now when you insert a record, do not include the date/time column in the
insert sql statement and the current date/time will be entered.
But, this will not enter the current date/time if the record is updated, this
must be done in the sql statement.
Ken
The ScareCrow Guest



Reply With Quote

