求各路大神解答 在线等 十万火急!!!
protectedvoidEdit_Click(objectsender,EventArgse){if((string)Session["Name"]!=""){if((...
protected void Edit_Click(object sender, EventArgs e)
{
if ((string)Session["Name"] != "")
{
if ((string)Session["role"] == "管理员")
{
string id = (string)Session["ID"];
//string name=Session["userName"];
string sql = "select * from [Tb_User_Login] where ID='" + id + "'";
string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString;
SqlConnection Sqlconn = new SqlConnection(connstr);
SqlDataAdapter sda = new SqlDataAdapter(sql, Sqlconn);
SqlCommandBuilder sc = new SqlCommandBuilder(sda);
DataSet ds = new DataSet();
sda.Fill(ds, "temp");
ds.Tables["temp"].DefaultView.Sort = "id";
int index = ds.Tables["temp"].DefaultView.Find(id);
ds.Tables["temp"].Rows[index]["ID"] = TxtUserID.Text.Trim();
ds.Tables["temp"].Rows[index]["userName"] = TxtUser.Text.Trim();
ds.Tables["temp"].Rows[index]["userPass"] = TxtPass.Text.Trim();
ds.Tables["temp"].Rows[index]["userRole"] = role.SelectedValue.Trim();
int rows = sda.Update(ds, "temp");
lbMessage.Text = "您已成功更新" + rows + "条记录!";
}
else
{
Response.Write("<script>alert('只有管理员才可以进行此操作!')</script>");
}
}
else
{
Response.Redirect("Default.aspx"); ;
}
} 展开
{
if ((string)Session["Name"] != "")
{
if ((string)Session["role"] == "管理员")
{
string id = (string)Session["ID"];
//string name=Session["userName"];
string sql = "select * from [Tb_User_Login] where ID='" + id + "'";
string connstr = ConfigurationManager.ConnectionStrings["Mispersonalconn"].ConnectionString;
SqlConnection Sqlconn = new SqlConnection(connstr);
SqlDataAdapter sda = new SqlDataAdapter(sql, Sqlconn);
SqlCommandBuilder sc = new SqlCommandBuilder(sda);
DataSet ds = new DataSet();
sda.Fill(ds, "temp");
ds.Tables["temp"].DefaultView.Sort = "id";
int index = ds.Tables["temp"].DefaultView.Find(id);
ds.Tables["temp"].Rows[index]["ID"] = TxtUserID.Text.Trim();
ds.Tables["temp"].Rows[index]["userName"] = TxtUser.Text.Trim();
ds.Tables["temp"].Rows[index]["userPass"] = TxtPass.Text.Trim();
ds.Tables["temp"].Rows[index]["userRole"] = role.SelectedValue.Trim();
int rows = sda.Update(ds, "temp");
lbMessage.Text = "您已成功更新" + rows + "条记录!";
}
else
{
Response.Write("<script>alert('只有管理员才可以进行此操作!')</script>");
}
}
else
{
Response.Redirect("Default.aspx"); ;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询