Hi, I'm developing an ASP.NET app with a MySQL backend, using the MySQL Connector Net 6.2.3. I have a DetailsView with an insert command that is throwing the error:
MySql.Data.MySqlClient.MySqlException: 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 '?,?,?,?,?,?,?,?)'
at line 1
My code is:
If I hardcode values into the insert statement, it works fine. But when I put the ? placeholder in, it throws the error. Can anyone help me pinpoint the problem or offer a workaround solution?
Member
1 Points
2 Posts
Insert command throws MySQL error when using parameter placeholder
Apr 21, 2010 01:57 PM|steinj14|LINK
Hi, I'm developing an ASP.NET app with a MySQL backend, using the MySQL Connector Net 6.2.3. I have a DetailsView with an insert command that is throwing the error:
MySql.Data.MySqlClient.MySqlException: 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 '?,?,?,?,?,?,?,?)' at line 1
My code is:
If I hardcode values into the insert statement, it works fine. But when I put the ? placeholder in, it throws the error. Can anyone help me pinpoint the problem or offer a workaround solution?
Thanks, Joan
All-Star
193986 Points
28020 Posts
Moderator
Re: Insert command throws MySQL error when using parameter placeholder
Apr 21, 2010 04:06 PM|Mikesdotnetting|LINK
I believe the syntax for your provider is to follow the parameter name after the ?
Eg: INSERT INTO coupons (userid, title, line1, line2, terms, startdate, expdate, code) VALUES (?userid,?title,?line1,?line2,?terms,?startdate,?expdate,?code)
Member
1 Points
2 Posts
Re: Insert command throws MySQL error when using parameter placeholder
Apr 22, 2010 06:48 AM|steinj14|LINK
Thanks, that worked perfectly. Still trying to learn the differences between SQL Server and MySQL syntax...