asp.net中数据库更新问题
protectedvoidPage_Load(objectsender,EventArgse){}protectedvoidok5_Click(objectsender,...
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ok5_Click(object sender, EventArgs e)
{
string power = "";
if (CheckBox1.Checked)
{
power += CheckBox1.Text + ",";
}
if (CheckBox2.Checked)
{
power += CheckBox2.Text + ",";
}
if (CheckBox3.Checked)
{
power += CheckBox3.Text + ",";
}
if (CheckBox4.Checked)
{
power += CheckBox4.Text + ",";
}
SqlConnection Conn = new SqlConnection(DBhelper.strCon);
Conn.Open();
SqlCommand Cmd = new SqlCommand("update TUser set UserPWD='" + TextBox2.Text + "',RealName='" + TextBox4.Text + "',Sex='" + DropDownList2.Text + "', Power='" + power + "',Phone='" + TextBox5.Text + "',Remark='" +DropDownList3.Text +"' where UserName="
+ DropDownList1.Text, Conn);
//我这里的DropDownList1.Text的值是我数据库表中主键的值,点击按扭后为什么会老说我列名无效啊?
Cmd.ExecuteNonQuery();
Utils.AlertBox("修改成功!");
Conn.Close();
} 展开
{
}
protected void ok5_Click(object sender, EventArgs e)
{
string power = "";
if (CheckBox1.Checked)
{
power += CheckBox1.Text + ",";
}
if (CheckBox2.Checked)
{
power += CheckBox2.Text + ",";
}
if (CheckBox3.Checked)
{
power += CheckBox3.Text + ",";
}
if (CheckBox4.Checked)
{
power += CheckBox4.Text + ",";
}
SqlConnection Conn = new SqlConnection(DBhelper.strCon);
Conn.Open();
SqlCommand Cmd = new SqlCommand("update TUser set UserPWD='" + TextBox2.Text + "',RealName='" + TextBox4.Text + "',Sex='" + DropDownList2.Text + "', Power='" + power + "',Phone='" + TextBox5.Text + "',Remark='" +DropDownList3.Text +"' where UserName="
+ DropDownList1.Text, Conn);
//我这里的DropDownList1.Text的值是我数据库表中主键的值,点击按扭后为什么会老说我列名无效啊?
Cmd.ExecuteNonQuery();
Utils.AlertBox("修改成功!");
Conn.Close();
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询