470,596 Members | 1,396 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

syntax error near ',' in insert command

hi,can anybody tell reason for getting syntax error near , while either updating or inserting records in table
Sep 12 '07 #1
3 2127
markrawlingson
346 Expert 100+
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
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
346 Expert 100+
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.

Similar topics

reply views Thread by Thiko | last post: by
8 posts views Thread by Kevin Murphy | last post: by
1 post views Thread by Sandesh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.