【发布时间】:2014-08-10 17:54:01
【问题描述】:
当我尝试在名为“表”的数据表的 mysql 数据库数组值中插入时遇到 SQL 语法错误。
ERROR [42000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.27-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right.
数据表 = 表;
代码如下:
for (int x = 0; x < table.Rows.Count; x++)
{
conn.Open();
OdbcCommand command = new OdbcCommand("INSERT INTO jevslimporttemp(JevSLImportTempCode, JevSLImportTempDescription, JevSLImportTempAmount)VALUES('" + table.Rows[x][0].ToString() + "','" + table.Rows[x][1].ToString() + "','" + Convert.ToDouble(table.Rows[x][2].ToString()) + "');", conn);
command.ExecuteNonQuery();
conn.Close();
}
【问题讨论】:
-
编辑问题并在变量替换后打印出字符串。
-
这里提到的错误
-
当您使用它时,无需水平滚动即可使您的查询可读。
-
我只是尝试在消息框中输出字符串,它工作正常。但是当我使用查询字符串将它插入数据库时,我得到了一个错误。谁能告诉我查询的哪一部分出错了?
-
这里提到的错误