【发布时间】:2014-06-14 01:05:56
【问题描述】:
ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.5.9-log]您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册以获取正确的语法,以便在 'CALL spCreateTrade (27756,'27751','820','1','126','TRADE','Approved')' 附近使用第 1 行
此查询在 MySQL 工作台等编辑器中运行良好。我使用了相同的 SQL 用户。我一生都无法弄清楚为什么这不起作用。
parameters.Add(new OdbcParameter("pEmployeeDB_ID", co.DB_ID));
parameters.Add(new OdbcParameter("pOther_EmployeeDB_ID", EmployeeDB_ID.ToString()));
parameters.Add(new OdbcParameter("pCO_ID", CO_ID.ToString()));
parameters.Add(new OdbcParameter("pDPID", co.Department_Position_ID.ToString()));
parameters.Add(new OdbcParameter("pCompleted_By", Completed_By.ToString()));
parameters.Add(new OdbcParameter("pAction_type", "TRADE"));
parameters.Add(new OdbcParameter("sStatus", "Approved"));
string sql = "CALL spCreateTrade (?,?,?,?,?,?,?)";
DataSet retVal = new DataSet();
if (connString != null)
{
using (OdbcConnection connection = new OdbcConnection(connString))
{
//Open it
connection.Open();
//Create the command
OdbcCommand command = new OdbcCommand(sql, connection);
command.CommandType = cmdType;
if (parameters != null)
{
foreach (OdbcParameter p in parameters)
{
command.Parameters.Add(p);
}
}
command.ExecuteNonQuery();
//Close the connection.
connection.Close();
}
}
【问题讨论】:
标签: c# mysql asp.net .net odbc