ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 24th, 2005, 11:42 AM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
access sql syntax w/ coldfusion

I've been looking at this error for days and can't seem to find anything wrong to return this error, if I enter the data manually and fill out all the fields and put it in Access, it works, but then using CF to pass this returns an error below......

ODBC Error Code = 37000 (Syntax error or access violation)

[Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.

SQL = "INSERT INTO tblfachecklist(studentid, faa, spcs, uda, rs, fdlc, eccf, ec, xc, mailoutdate, dpl, dl, ssac, ac, ofafsa, iir, anr, isir, ssc, insv, ts, vw, sbstu, sbpar, sbspo, tax, spn, plus, ccd, lc, rc, nt, add1, add2, add3) VALUES(1649, 1, 1, 0, 0, 0, 0, 0, 0, , 0, 0, 0, 0, , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, , 0, 0, 0, 0, , , , , )"


the query
<cfquery datasource=#aihs# name="newfachecklist">

INSERT INTO tblfachecklist(studentid, faa, spcs, uda, rs, fdlc, eccf, ec, xc, mailoutdate, dpl, dl, ssac, ac, ofafsa, iir, anr, isir, ssc, insv, ts, vw, sbstu, sbpar, sbspo, tax, spn, plus, ccd, lc, rc, nt, add1, add2, add3) VALUES(#studentid#, #faa#, #spcs#, #uda#, #rs#, #fdlc#, #eccf#, #ec#, #xc#, #mailoutdate#, #dpl#, #dl#, #ssac#, #ac#, #ofafsa#, #iir#, #anr#, #isir#, #ssc#, #insv#, #ts#, #vw#, #sbstu#, #sbpar#, #sbspo#, #tax#, #spn#, #plus#, #ccd#, #lc#, #rc#, #nt#, #add1#, #add2#, #add3#)

</cfquery>

all the fields are type YES/NO except these

studentid - number
mailoutdate - date/time
ofafsa - text
tax - text
rc - text
nt - date/time
add1 - text
add2 - text
add3 - text

would appreciate any suggestions, thanks, I did put single quotes around the text items but that didn't seem to help

Reply With Quote
  #2  
Old June 24th, 2005, 01:19 PM
jbird4k jbird4k is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Location: Maryland
Posts: 54 jbird4k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 40 m 18 sec
Reputation Power: 7
Send a message via ICQ to jbird4k Send a message via Yahoo to jbird4k
Quote:
Originally Posted by jdang
all the fields are type YES/NO except these

studentid - number
mailoutdate - date/time
ofafsa - text
tax - text
rc - text
nt - date/time
add1 - text
add2 - text
add3 - text

would appreciate any suggestions, thanks, I did put single quotes around the text items but that didn't seem to help


Here are two things that I would start with.
1. mailoutdate :: if the field in your access database is defined as a date/time field, then convert the input to odbc format --<cfset mydate = #createODBCdateTime(mailoutdate)#> the insert #mydate#

2. make sure that in your insert statement that all your text fields are surrounded by quotes, otherwise access looks at the data as numeric.

I use access as my back end quite abit and working with date fields always gives me a headache. when you output your date field you will have to use #dateformat(var,'mask')# to view the date in a easily readable format.

hope this helps
__________________
J. Birdsell,
www.carry-on-scheff-fans.com

Reply With Quote
  #3  
Old June 24th, 2005, 01:47 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 22 m 41 sec
Reputation Power: 53
I also think you can't pass in those empty comma separated values at the end of your statement. You either have to pass in something or don't pass in anything and take the columns out of the query.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #4  
Old June 24th, 2005, 01:53 PM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
actually, those empty commas is the actual output of the query dump from CF because those variables are empty strings, the original sql I wrote just pass variables, what should I do to pass empty strings? I tried assigning &nbsp; to the string if it's empty but that didn't seem to get rid of the error .... thanks

Reply With Quote
  #5  
Old June 24th, 2005, 01:59 PM
jbird4k jbird4k is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Location: Maryland
Posts: 54 jbird4k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 40 m 18 sec
Reputation Power: 7
Send a message via ICQ to jbird4k Send a message via Yahoo to jbird4k
Quote:
Originally Posted by jdang
actually, those empty commas is the actual output of the query dump from CF because those variables are empty strings, the original sql I wrote just pass variables, what should I do to pass empty strings? I tried assigning &nbsp; to the string if it's empty but that didn't seem to get rid of the error .... thanks



have you tried using <cfparam> to set null values for those strings?

Reply With Quote
  #6  
Old June 24th, 2005, 02:14 PM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
hmm, if i fill in something for the fields that are dates then the query gets executed ok and it inserts, so I guess I'll have to come up w/ some sort of default date?

Reply With Quote
  #7  
Old June 24th, 2005, 02:21 PM
jbird4k jbird4k is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2001
Location: Maryland
Posts: 54 jbird4k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 40 m 18 sec
Reputation Power: 7
Send a message via ICQ to jbird4k Send a message via Yahoo to jbird4k
Quote:
Originally Posted by jdang
hmm, if i fill in something for the fields that are dates then the query gets executed ok and it inserts, so I guess I'll have to come up w/ some sort of default date?



go into access, in design view for the table click on the date field and on the general tab. make sure required is set to "NO"

I would do the same for the other fields that would normally be blank.

Reply With Quote
  #8  
Old June 24th, 2005, 02:28 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 22 m 41 sec
Reputation Power: 53
If you want it to pass empty strings you must use '#faa#' which if faa was an empty string would end up being ''. Note that ALL of your string-based columns MUST have quotes around the values or the query will fail (this is not a CF thing it is a database thing).

Reply With Quote
  #9  
Old June 24th, 2005, 03:30 PM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
Quote:
Originally Posted by jbird4k
go into access, in design view for the table click on the date field and on the general tab. make sure required is set to "NO"

I would do the same for the other fields that would normally be blank.



I already did that to all of the fields in the db, I just looked over my other project I did long time ago, I had to put a default date in there so I think I'm just gonna put some fictitious date in there, unless there's a better way ...... thanks guys

Reply With Quote
  #10  
Old June 24th, 2005, 05:19 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,681 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 22 m 41 sec
Reputation Power: 53
Well the best way is to put quotes around string values and pass the correct columns.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > access sql syntax w/ coldfusion


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT