超級奇怪的問題!
我的ACCESSDataSource 頁面代碼如下:
<asp:AccessDataSource ID= "database " runat= "server " DeleteCommand= "DELETE FROM [ArticleTag] WHERE [num] = @num " SelectCommand= "SELECT [TagName], [Times], [num] FROM [ArticleTag] Order By [Times] DESC "
UpdateCommand= "UPDATE [ArticleTag] SET [TagName] = @TagName, [Times] = @Times WHERE [num] = @num " OnUpdating= "database_OnUpdatings ">
<UpdateParameters>
<asp:Parameter Name= "TagName " Type= "String " />
<asp:Parameter Name= "Times " Type= "Int32 " />
<asp:Parameter Name= "num " Type= "Int32 " />
</UpdateParameters>
<DeleteParameters>
<asp:Parameter Name= "num " Type= "Int32 " />
</DeleteParameters>
</asp:AccessDataSource>
主要是這里面有個 OnUpdating 事件,
然后在CS頁面我下了如下代碼:
protected void database_OnUpdatings(object sender,OleDbRowUpdatingEventArgs e)
{
//检测大类名
//大类名称不能为空
if (e.Command.Parameters[ "@TagName "].Value == null)
{
Response.Write( " <script language= 'javascript '> alert( '关键词名称不能为空,请填写关键词 '),history.go(-1) </script> ");
Response.End();
}
}
然后出現編譯錯誤:
编译器错误信息: CS0123: “database_OnUpdatings”的重载均与委托“System.Web.UI.WebControls.SqlDataSourceCommandEventHandler”不匹配
我就奇怪了,那里來的Sqldatasource啊。。。。
大家幫看下怎么回事。
[解决办法]
你这个事件的定义不对吧,或者你没有继承SqlDataSourceCommandEventHandler
[解决办法]
AccessDataSource的参数不能使用@num的格式,是用?
然后参数声明的顺序要和?的顺序一致