C#中如何删除数据库中的用户
若以下回答无法解决问题,邀请你更新回答
2个回答
展开全部
/// <summary>
/// 删除行数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
conn.Open();
string delid = GridView1.DataKeys[e.RowIndex].Value.ToString();
string cmdtext = "delete from USER_INFO where uid='" + delid + "'";
SqlCommand cmd = new SqlCommand(cmdtext, conn);
cmd.ExecuteNonQuery();
conn.Close();
GridView1.DataSource = GetUserInfo();
GridView1.DataBind();
}
/// 删除行数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
conn.Open();
string delid = GridView1.DataKeys[e.RowIndex].Value.ToString();
string cmdtext = "delete from USER_INFO where uid='" + delid + "'";
SqlCommand cmd = new SqlCommand(cmdtext, conn);
cmd.ExecuteNonQuery();
conn.Close();
GridView1.DataSource = GetUserInfo();
GridView1.DataBind();
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼上说的就很详细了。我就不说了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询