我有下面的代码,它通过将参数与表中的主键匹配来触发存储过程来删除记录。我通过调试运行代码,一切都正确分配,但我不断收到错误消息,指出指定的参数太多。我认为这与我的存储过程有关,因为这些值已正确分配。
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
Dim CurrentCommand As String = e.CommandName
Dim CurrentRow As Integer = Int32.Parse(e.CommandArgument.ToString())
Dim ID As String = GridView1.DataKeys(CurrentRow).Value
sqlds.DeleteParameters.Add("KeyOpType", ID)
sqlds.Delete()
End Sub
SQL Server 2008 中的存储过程
ALTER PROCEDURE [dbo].[GetGenInfo_DeleteMines]
(@KeyOpType int)
AS
Delete FROM GenInfo_OpType
Where KeyOpType = @KeyOpType