[求助]datagrid中删除数据问题
帮忙给看看这段代码。删除的效果没有实现,应该怎么改啊?private void btn(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
switch(((Button)e.CommandSource).CommandName)
{
case "shanchu":
int strid=Convert.ToInt32(e.Item.ItemIndex);
SqlConnection conn=new SqlConnection("server=localhost; database=wkm001; uid=sa; pwd=");
conn.Open();
SqlCommand com=new SqlCommand("delete_and_select", conn);
com.Parameters.Add(
new SqlParameter("@strid ", SqlDbType.Int)).Value=strid;
com.CommandType=CommandType.StoredProcedure;
SqlDataReader dr=com.ExecuteReader();
if(dr.Read())
{
DataGrid DG=new DataGrid();
this.DG.DataSource=dr;
this.DG.DataBind();
dr.Close();
com.Dispose();
conn.Close();
}
break;
存储过程:
CREATE PROCEDURE [dbo].[delete_and_select]
@strid int
AS
begin
delete from person where person.id=@strid
end
begin
select * from person
end
GO