【发布时间】:2017-03-10 11:09:04
【问题描述】:
我在这段代码中找不到什么错误。据我说这很好,希望能正确执行,但我收到一个错误:
错误 [42000] [MySQL][ODBC 3.51 驱动程序][mysqld-5.7.11]
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“ViewBatchByID”附近使用正确的语法
我的代码是
string Message = null;
OdbcCommand Cmd = new OdbcCommand();
Cmd.Connection = Connection.con;
Cmd.CommandText = "ViewBatchByID";
Cmd.CommandType = CommandType.StoredProcedure;
Cmd.Parameters.AddWithValue("@p0", 1);
try
{
Cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
Message = ex.Message.ToString();
}
这里 ViewBatchByID 是我的存储过程,它在服务器上运行良好。
【问题讨论】:
-
我同时使用了“command.Parameters.Add()”或“command.Parameters.AddWithValue()”和参数方向但是我得到了同样的错误。
-
实际过程中参数名称为@p0 ?
-
我也使用它,但我得到一个错误或参数空值 OdbcCommand cmd=("{call ViewBatchByID (?)}",Connection.con);