我對刪除這個樣子的隱藏代碼:存儲過程不起作用?
protected void delete(object sender, GridViewDeleteEventArgs e)
{
sc.connection();
//string st = "delete";
int id = Convert.ToInt32(((Label)(GridView1.Rows[e.RowIndex].FindControl("lblpro2"))).Text);
SqlCommand cmd = new SqlCommand("maniputale", sc.con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@action", "delete");
cmd.Parameters.AddWithValue("@mysid", 6);
//cmd.Parameters.Add("@action", SqlDbType.VarChar,50).Value= st;
//cmd.Parameters.Add("@mysid", SqlDbType.Int).Value = id;
cmd.ExecuteNonQuery();
}
,並且存儲過程是:
ALTER PROCEDURE maniputale
(
@mysid int = null,
@myproducts nvarchar(20) = null,
@mydescription varchar(50) = null,
@myprice int = null,
@mybrand varchar(20) = null,
@mymid int = null,
@action varchar = null
)
as
Begin
set NOCOUNT ON;
if @action = 'insert'
Begin
Insert into sub_catTbl(products,description,price,brand,mid)
values(@myproducts,@mydescription,@myprice,@mybrand,@mymid)
End
else if @action = 'select'
Begin
select * from sub_catTbl
End
else if @action = 'update'
Begin
update sub_catTbl set [email protected],description = @mydescription,price [email protected],[email protected],[email protected]
End
else if @action = 'delete'
Begin
delete from sub_catTbl where [email protected];
End
End
但它不工作。它既不顯示任何變化也不顯示錯誤。
是否有任何方法來檢查存儲過程是否正在執行就像我們有linebreaker來檢查.cs文件?
請提供完整的SP源代碼 - 或者製作一個** **的最小示例,以顯示問題。 –
http://meta.stackexchange.com/questions/10647/how-do-i-write-a-good-title –
'@ action'是什麼類型?如果它是'char(x)'或'nchar(x)',比較可能會失敗,因爲'char'和'nchar'用空格填充內容直到達到'x'。 –