MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL 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, 2004, 05:26 PM
battlecat battlecat is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 24 battlecat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Can anyone see what's wrong with this? (MS Access query)

Hi, I hope this is in the right forum!

I'm trying to do something extremely simple, but I keep getting this error:

Runtime error '3134' Syntax error in INSERT INTO statement

This is the code it complains about:

CurrentDb.Execute "Insert Into Speechfiles(FileName, SpeakerID,
SamplingRate,
DirectoryPathID,
Text,
CreationDate,
Duration,
Range)

values

(" & Chr(34) & fName & Chr(34) & ",
" & spkrID & ",
" & rate & ",
" & dirPathID & ",
" & Chr(34) & txt & Chr(34) & ",
" & Chr(34) & crdate & Chr(34) & ",
" & duration & ",
" & range & ")"

Since its so long, I've shown it as multiple lines, but in my code it is one long statement:

CurrentDb.Execute "Insert into Speechfiles(...) values (...)"

The table is called Speechfiles and the fields are as follows (types are in brackets)

FileName (text)
SpeakerID (number)
SamplingRate (number)
DirectoryPathID (number)
Text (text)
CreationDate (text) <- this isn't date format, so not the prob
Duration (number)
Range (number)

and the values I'm trying to insert are all of the same type as the fields are.... SOOOOOOOOOOOOOooooo, can anyone spot anything? I've spent way to long on this. All my other CurrentDb.Execute "Insert Into...." statements are working fine, it's just this one!

Thanks so much in advance...

Reply With Quote
  #2  
Old June 24th, 2004, 07:53 PM
battlecat battlecat is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 24 battlecat User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If anyone's ever interested, the way I fixed this problem was putting [] around the the field names of the table

ex:

"Insert Into Speechfiles([FileName], [SpeakerID], ...., [Range]) values (.....)"

go figure!! I don't think any of those names are reserved words or anything, so I'm not sure why this fixed the problem, but it is!

Reply With Quote
  #3  
Old July 13th, 2004, 03:45 AM
Sequel Sequel is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 1 Sequel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You also may want to try executing a string variable rather than typing the SQL query out each time.

I.e.

stSQL = "INSERT INTO tblYourTable(etc...."

Current.db execute stSQL

That way, you should be able to omit the [] around field names.

Reply With Quote
  #4  
Old July 13th, 2004, 12:45 PM
ambals03 ambals03 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 2 ambals03 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
try quotes

whereever its text - try single quotes - i've shown for filename:

"Insert Into Speechfiles(FileName, SpeakerID,
SamplingRate,
DirectoryPathID,
Text,
CreationDate,
Duration,
Range)

values

( ' " & fName & " ',
" & spkrID & ",
" & rate & ",
" & dirPathID & ",
" & Chr(34) & txt & Chr(34) & ",
" & Chr(34) & crdate & Chr(34) & ",
" & duration & ",
" & range & ")"

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Can anyone see what's wrong with this? (MS Access query)


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 3 hosted by Hostway