在集合中找不到参数“created_on”

时间:2013-05-18 09:30:21

标签: c# asp.net mysql

我将三个参数传递给存储过程,两个参数没有问题,但是没有识别出一个参数。这是代码:

    MySqlCommand cmd = new MySqlCommand("AppTableDetails", connection);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.AddWithValue("@tname",tablename);
        cmd.Parameters.AddWithValue("@created_on",definedon);
        cmd.Parameters.AddWithValue("@createdBy", createdby);
        connection.Open();
        cmd.ExecuteNonQuery();

        connection.Close();

存储过程是:

    ALTER DEFINER=`root`@`localhost` PROCEDURE `AppTableDetails`( IN tname varchar(40),

IN created_on datetime,
IN createdBy varchar(40))
BEGIN
insert into `app_tables` (tablename,tableid,defined_on,appid,created_by)
values ( tname,0,created_on,(select max(appid) from application), createdBy);
END

当我调试文件时,我收到一个错误:在集合中找不到参数“created_on”。但我已经清楚地写了存储过程。有什么问题?帮助

1 个答案:

答案 0 :(得分:0)

IN created_on datetime更改为IN created_on varchar(40),

IN created_on datetime更改为IN created_on DATETIME = NULL,