-5

C# keeps coming up with an error:

Additional information: 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 '2pcs Fashion Cool Universal Black Real Original Car Headlight Eyelashes Sticker,' at line 1

My SQL statement is at the bottom in the picture.

http://i42.tinypic.com/350uqm9.png

Carth
  • 2,303
  • 1
  • 17
  • 26

2 Answers2

4

The answer is that you have not written the correct SQL.

First, you have embedded values for the SQL directly into the SQL. This is most often prone to SQL Injection attacks.

Basically, you should not do this.

But let's let that slide for a moment.

(Secondly) If you were to properly embed values directly into the SQL, you need to quote strings.

This is not legal:

INSERT INTO some_table (some_varchar_column) VALUES (some text)

This is legal:

INSERT INTO some_table (some_varchar_column) VALUES ('some text')
                                                     ^         ^

Notice the quotes? You're missing them.

But, you should use Parameterized Queries.

Community
  • 1
  • 1
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
0

your literal text should be surrounded by single quotes.

Randy
  • 16,480
  • 1
  • 37
  • 55