4 Replies - 730 Views - Last Post: 26 August 2013 - 09:59 AM Rate Topic: -----

#1 Tristan Karl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 04-August 13

You have an error in your SQL syntax; check the manual error---mysql

Posted 26 August 2013 - 09:39 AM

Hi!
This is the code I have used:
 sqlinsert.CommandText = "INSERT INTO checkreordercritical VALUES ('" & ds2.Tables("Products").Rows(0).Item(0) & "','" & ds2.Tables("Products").Rows(0).Item(1) & "','" & ds2.Tables("Products").Rows(0).Item(2) & "','" & ds2.Tables("Products").Rows(0).Item(3) & "','" & ds2.Tables("Products").Rows(0).Item(4) & "','" & ds2.Tables("Products").Rows(0).Item(5) & "','" & ds2.Tables("Products").Rows(0).Item(6) & "','" & ds2.Tables("Products").Rows(0).Item(7) & "','" & ds2.Tables("Products").Rows(0).Item(8) & "','" & ds2.Tables("Products").Rows(0).Item(9) & "','" & ds2.Tables("Products").Rows(0).Item(10) & "','" & ds2.Tables("Products").Rows(0).Item(11) & "','" & ds2.Tables("Products").Rows(0).Item(12) & "','" & ds2.Tables("Products").Rows(0).Item(13) & "','" & ds2.Tables("Products").Rows(0).Item(14) & "','" & ds2.Tables("Products").Rows(0).Item(15) & "','" & ds2.Tables("Products").Rows(0).Item(16) & "','" & ds2.Tables("Products").Rows(0).Item(17) & "','" & ds2.Tables("Products").Rows(0).Item(18) & "','" & ds2.Tables("Products").Rows(0).Item(19) & "','Reorder')"


However, I get this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '5 OUNCES','Green','0','0','0','koko','0','60','20','10','0','LA','Re' at line 1

Please help me with this. Thanks in advance!God bless

Is This A Good Question/Topic? 0
  • +

Replies To: You have an error in your SQL syntax; check the manual error---mysql

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9055
  • View blog
  • Posts: 33,988
  • Joined: 12-June 08

Re: You have an error in your SQL syntax; check the manual error---mysql

Posted 26 August 2013 - 09:43 AM

I'll start off with - don't combine strings to make your SQL statement. Use parameters.

Also, typically, INSERT statements explicitly list out the column names BEFORE the values to insert.
Was This Post Helpful? 0
  • +
  • -

#3 ybadragon  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 192
  • View blog
  • Posts: 1,182
  • Joined: 11-May 12

Re: You have an error in your SQL syntax; check the manual error---mysql

Posted 26 August 2013 - 09:51 AM

To go with what Modi123_1 said about using parameters in your query, if you do that make sure they are in the same order as your database columns are, otherwise you may get a generic datatype mismatch error or the data may not be inserted at all.
Was This Post Helpful? 0
  • +
  • -

#4 Tristan Karl  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 04-August 13

Re: You have an error in your SQL syntax; check the manual error---mysql

Posted 26 August 2013 - 09:56 AM

View Postmodi123_1, on 26 August 2013 - 09:43 AM, said:

I'll start off with - don't combine strings to make your SQL statement. Use parameters.

Also, typically, INSERT statements explicitly list out the column names BEFORE the values to insert.


I have tried the first thing you said, but it did not work.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9055
  • View blog
  • Posts: 33,988
  • Joined: 12-June 08

Re: You have an error in your SQL syntax; check the manual error---mysql

Posted 26 August 2013 - 09:59 AM

Really? Where did you try it? Let's see it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1