I'm inserting multiple rows into a DB, and joining them together in an attempt to improve performance.
I get an ODBCException telling me my SQL syntax is wrong. But when I try it in the mysql commandline client, it works just fine..
I ran a simplified test to describe the process.
Command Line Client:
mysql> create table test (`id` int, `name` text);
Query OK, 0 rows affected (0.05 sec)
mysql> INSERT INTO test(id, name) VALUES ('1', 'Foo');INSERT INTO test(id, name) VALUES ('2', 'bar');
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
mysql>
After that I ran this code on the same DB:
comm.CommandText = "INSERT INTO test(id, name) VALUES ('1', 'Foo');INSERT INTO test(id, name) VALUES ('2', 'bar');";
comm.ExecuteNonQuery();
which gives me the following error:
+ base {"ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.1.51-community]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 'INSERT INTO test(id, name) VALUES ('2', 'bar')' at line 1"} System.Data.Common.DbException {System.Data.Odbc.OdbcException}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…