我的存储过程加入注释就出现Parameter '?/*' not found in the collection错误该怎么办?
//下面是我的存储过程,我call过存储过程了,是没有问题的.
CREATE DEFINER=`root`@`localhost` PROCEDURE `P_SearchWordNote`( /* 2007 11 19 查询留言信息 */
in WordID int,
in BegTime varchar(20),
in EndTime varchar(20)
)
Begin
/*declare WordID int;
declare BegTime varchar(20);
declare EndTime varchar(20);*/
declare BegDate datetime;
declare EndDate datetime;
if( BegTime = "0" or BegTime = "") then
set BegDate = DATE_ADD(current_Date(),interval -10 year);
else
set BegDate = CAST( BegTime as datetime );
end if;
if( EndTime = "0" or EndTime = "") then
set EndDate = CURRENT_DATE();
else
set EndDate = cast( EndTime as datetime );
End if;
if( WordID > 0) then
update BaySpeed.KF_WordNote set WN_SeeOk = 1 where WN_ID = WordID;
select * from BaySpeed.KF_WordNote where WN_ID = WordID;
else
select * from BaySpeed.P_WordListView where (WN_AddTime >= BegDate) and ( WN_AddTime <= EndDate );
End if;
END$$
//下面是.net中调用的代码
sqlConn.Open();
MySqlCommand myComm = new MySqlCommand("P_SearchWordNote", sqlConn);
myComm.CommandType = CommandType.StoredProcedure;
myComm.Connection = sqlConn;
myComm.CommandText = "P_SearchWordNote";
MySqlParameter P1 = new MySqlParameter("?WordID", MySqlDbType.Int32);
P1.Value = WordID;
P1.Direction = ParameterDirection.Input;
myComm.Parameters.Add(P1);
//myComm.Parameters.Add(new MySqlParameter("WordID", WordID));
//myComm.Parameters.Add(new MySqlParameter("BegTime", BegTime));
//myComm.Parameters.Add(new MySqlParameter("EndTime", EndTime));
MySqlParameter P2 = new MySqlParameter("?BegTime", MySqlDbType.VarChar, 20);
P2.Value = BegTime;
P2.Direction = ParameterDirection.Input;
myComm.Parameters.Add(P2);
MySqlParameter P3 = new MySqlParameter("?EndTime", MySqlDbType.VarChar, 20);
P3.Value = EndTime;
P3.Direction = ParameterDirection.Input;
myComm.Parameters.Add(P3);
MySqlDataAdapter adapter = new MySqlDataAdapter();
DataSet ds = new DataSet();
adapter.SelectCommand = myComm;
adapter.Fill(ds);
sqlConn.Close();
return ds;
//运行后就出现这个错误了(万分感激,如果去掉注释就没有问题了)
Parameter '?/*' not found in the collection
------解决方案--------------------注释位置不对。
把
/* 2007 11 19 查询留言信息 */
放在CREATE 的前一行试试。
------解决方案--------------------SQL code
delimiter ||
CREATE DEFINER=`root`@`localhost` PROCEDURE `P_SearchWordNote`( /* 2007 11 19 查询留言信息 */
in WordID int,
in BegTime varchar(20),
in EndTime varchar(20)
)
Begin
/*declare WordID int;
declare BegTime varchar(20);
declare EndTime varchar(20);*/
declare BegDate datetime;
declare EndDate datetime;
if BegTime = "0" or BegTime = "" then
set BegDate = DATE_ADD(current_Date(),interval -10 year);
else
set BegDate = CAST( BegTime as datetime );
end if;
if EndTime = "0" or EndTime = "" then
set EndDate = CURRENT_DATE();
else
set EndDate = cast( EndTime as datetime );
End if;
if WordID > 0 then
update BaySpeed.KF_WordNote set WN_SeeOk = 1 where WN_I