简体   繁体   中英

When using the Toolbox in Visual Studio 2010 to pull data from a MySQL server, keeps giving errors

In my table called "test01" I keep getting an error when I run the site.

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 '[test01]' at line 1

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: 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 '[test01]' at line 1

From what I can see it is because the code that it is generating when I bring toolbox items and drop them in design view is this:

SelectCommand="SELECT * FROM [test01]" 
        DeleteCommand="DELETE FROM [test01] WHERE [test_id] = ?" 
        InsertCommand="INSERT INTO [test01] ([test_id], [TestName], [TestDescription]) VALUES (?, ?, ?)" 
        UpdateCommand="UPDATE [test01] SET [TestName] = ?, [TestDescription] = ? WHERE [test_id] = ?">

When I remove the [ ] brackets it works fine. Is there something I can do to change the functionality of this?

I hope this question makes sense!

Brackets are a MSSQL way of qualifying stuff. You want backticks for MySQL.

SELECT * FROM `test01`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM