Gasper Gasper - 9 months ago 54
C# Question

Incorrect syntax near parameter (C# with SQL)

I've got a problem that's driving me crazy. I get an exception "Incorrect syntax near "@p1" " when I'm inserting data into my database.


I looked for solutions on the internet but nothing solved this problem so far. Does anyone have a clue what is wrong with my code?
Thanks! (By the way, sorry for some foreign language in code. It's a school project and the school that I'm attending is not english)

Answer Source

You got your insert syntax wrong, it should be:

INSERT INTO Leti VALUES ( @p1,@p2,@p3,.....)
                        ^                  ^
                        |-you missed these-|