By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,867 Members | 1,981 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,867 IT Pros & Developers. It's quick & easy.

error on sql insert

P: 5
hi
I am getting an error :
on execute statement ! :

error is :

Microsoft OLE DB Provider for SQL Server error '80040e14'
Incorrect syntax near ','.

--------------------------------
this is the statement :

Expand|Select|Wrap|Line Numbers
  1. sql = "insert into requirements (message, priority,server, ip, usr, creationTime, modificationTime, Title, deleted, " &_
  2. "EventName, PriorityComm, Service, CallRef, Description, DateTimeIncident, BusinessImpact, NextSteps) values " &_
  3. "('" & strData & "', " & priority & ", '" & ip & "', '" & usr & "', GetDate(), GetDate(),'" & title & "','" & eventName & "') " &_ 
  4. "('" & priorityComm & "','" & service & "','" & callRef & "','" & description & "', GetDateTime(),'" & businessImpact & "','" & nextSteps & "') "
  5.  
  6.  
  7. DbObj.Execute(SQL)
  8. on error resume next


any help would be much appreciated .


Thanks
Oct 16 '13 #1
Share this Question
Share on Google+
7 Replies


Expert 100+
P: 634
Hi

On initial inpection I think you need to change this
, GetDate(), GetDate(),
to this
," & GetDate() & ", " & GetDate() & ",

and this
, GetDateTime(),
to
," & GetDateTime() & ",

Or possibly even this
,#" & Format(GetDate(),"mm/dd/yyyy") & "#, #" & Format(GetDate(),"mm/dd/yyyy") & "#,
and
,#" & Format(GetDateTime(),"mm/dd/yyyy") & "#,

??

HTH
Oct 16 '13 #2

P: 5
sorry my mistake I have too many fields on the insert : it should be :
Expand|Select|Wrap|Line Numbers
  1. sql = "insert into requirements(message, priority, ip, usr, creationTime, modificationTime, Title,  " &_
  2.       "EventName, PriorityComm, Service, CallRef, Description,  DateTimeIncident, BusinessImpact, NextSteps) values " &_
  3.      "('" & strData & "', " & priority & ",'" & ip & "', '" & usr & "', GetDate(), GetDate(),'" & title & "','" & eventName & "',)" &_ 
  4.     "('" & priorityComm & "','" & service & "','" & callRef & "','" & description & "', GetDateTime(),'" & businessImpact & "','" & nextSteps & "') "     
  5.  
  6. I am still getting the error - could it be from 
  7. DbObj.Execute(SQL)
  8.  on error resume next
I will take your advise ... and see ....
Oct 16 '13 #3

P: 5
I tried replacing with " & GetDate() &" etc but still sam error
Oct 16 '13 #4

Expert 100+
P: 634
You have nit tried my suggestions?
Oct 16 '13 #5

P: 5
I tried that too - I got the error
Type mismatch: 'GetDate'
Oct 16 '13 #6

Expert 100+
P: 634
What does GetDate() return?

is it a date or a string?

I suggest you either insert msgbox SQL or debug.print sql before DbObj.Execute(SQL) and examine the resulting string and post it here if you use the debug.print optuon (the string will appear in the immediate window - Ctrl+G).
Oct 16 '13 #7

Rabbit
Expert Mod 10K+
P: 12,370
Please use code tags when posting code or formatted data.

You have extra parentheses at the end of line 3 and the beginning of line 4.
Oct 16 '13 #8

Post your reply

Sign in to post your reply or Sign up for a free account.