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

syntax error near ',' in insert command

P: 4
hi,can anybody tell reason for getting syntax error near , while either updating or inserting records in table
Sep 12 '07 #1
Share this Question
Share on Google+
3 Replies


markrawlingson
Expert 100+
P: 346
Because the syntax of your SQL statement is incorrect.

Show us your SQL statement so we can see it and possibly point out your error.

In addition, whenever you face a problem like this it's a good idea to Response.Write your SQL statement to see what it REALLY says.

Sincerely,
Mark
Sep 12 '07 #2

P: 4
Thank you markrawlingson..
this is the sql command i got error from tis line.following is the code for updating and inserting records in table


[conn.execute " update enquiry set Etype='" & text(1) & "', regid ='" & text(2) & "', cname='" & text(3) & "', address='" & text(4) & "', salesperson='" & text(5) & "', through='" & text(6) & "', contactperson='" & text(7) & "',phoff='" & text(8) & "',phres='" & text(9) & "', mobile=" & text(10) & ",faxno='" & text(11) & "', email='" & text(12) & "', edate='" & text(13)& "', etime='" & cdate(text(14)) & "', thruby='" & text(15) & "', dob='" & text(16) & "', anniversarydate='" & text(17) & "', refby='" & text(18) & "', segmentname='" & text(19) & "',enquirytype='" & text(20) & "', branchid='" & text(21) & "' where regid= '" & text(2) & "' and branchid='" & text(21) & "' "]
[conn.execute "insert into enquiry values('" & text(1) & "', '" & text(2) & "', '" & text(3) & "', '" & text(4) & "', '" & text(5) & "', '" & text(6) & "', '" & text(7) & "', '" & text(8) & "', '" & text(9) & "', " & text(10) & ", '" & text(11) & "', '" & text(12) & "', '" & text(13) & "','" & cdate(text(14)) & "', '" & text(15) & "','" & text(16) & "', '" & text(17) & "', '" & text(18) & "', '" & text(19) & "', '" & text(20) & "', '" & text(21) & "') "]
'



Because the syntax of your SQL statement is incorrect.

Show us your SQL statement so we can see it and possibly point out your error.

In addition, whenever you face a problem like this it's a good idea to Response.Write your SQL statement to see what it REALLY says.

Sincerely,
Mark
Sep 14 '07 #3

markrawlingson
Expert 100+
P: 346
The second conn.execute statement looks incorrect.

[conn.execute "insert into enquiry values('" & text(1) & "', '" & text(2) & "', '" & text(3) & "', '" & text(4) & "', '" & text(5) & "', '" & text(6) & "', '" & text(7) & "', '" & text(8) & "', '" & text(9) & "', " & text(10) & ", '" & text(11) & "', '" & text(12) & "', '" & text(13) & "','" & cdate(text(14)) & "', '" & text(15) & "','" & text(16) & "', '" & text(17) & "', '" & text(18) & "', '" & text(19) & "', '" & text(20) & "', '" & text(21) & "') "]

You're specifying values but no fields for them to go into..

The proper syntax for an INSERT INTO statement is as follows..

Expand|Select|Wrap|Line Numbers
  1. Conn.Execute "INSERT INTO Enquiry (column1, column2, column3, column4) VALUES ('value1',Value2',Value3',Value4')
  2.  
Try that. If that doesn't work then Set your SQL statements into a variable...

sSQL = "sql statement"

and response.write it out (Response.Write sSQL).. copy it and post it so we can see what it actually says.

The problem most people have with SQL, especially with dynamically constructed SQL statements, is that they're constructing the statement but they don't actually realize that the statement doesn't say what they intended.. thus it throws an error. Therefore it's always a good idea to spit it out onto the page so you can visually see what statement is being passed to the database. It may look correct in your code, especially if you've been looking at the screen for hours, but what's actually generated may be something completely different!

Sincerely,
Mark
Sep 15 '07 #4

Post your reply

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