我在这里要做的就是使用存储过程将状态字段设置为“完成”,但由于某种原因,在我运行存储过程后它没有更新我的表。有人可以在这里帮助我并告诉我我做错了什么吗?谢谢 //这里是存储过程
CREATE PROCEDURE sp_Update
@ID varchar
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
if exists (select Post_ID from MyTable WHERE Post_ID = @ID)
BEGIN
UPDATE MyTable
SET Status = 'Complete'
WHERE Post_ID = @ID
END
END
//and here is the code behind
foreach (GridViewRow gr in GV_Action.Rows)
{
//string strID = gr.Cells[1].Text;
string ID = gr.Cells[1].Text;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand("sp_Update", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = ID;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}