protected void btn_add_into_data_xitongyonghu_Click(object sender, EventArgs e)
{
OleDbConnection Conn = new OleDbConnection();
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("App_Data/bookguest.mdb");
Conn.Open();
OleDbCommand cmd1 = new OleDbCommand("select count(*) from systemuser where userName='" + this.yonghuming.Text.ToString() + "'", Conn);
int count = (int)cmd1.ExecuteScalar();
try
{
if ( count> 0)
{
this.xinxi.Text = "该用户名已存在";
}
else
{
string strinto = "insert into systemuser(userName,userPwd,userRight) valus ('"+this.yonghuming.Text.ToString()+","+this.mima.Text.ToString()+","+this.quanxiandengji.Text.ToString()+"')";
OleDbCommand cmd2 = new OleDbCommand(strinto, Conn);
// new OleDbCommand("insert into systemuser(userName,userPwd,userRight)values('" + this.yonghuming.Text.ToString() + "','" + this.mima.Text.ToString() + "','" + this.quanxiandengji.Text.ToString() + "')", Conn).ExecuteNonQuery();
Conn.Close();
}
}
finally
{
yonghuming.Text = "";
mima.Text = "";
quanxiandengji.Text = "身份证号";
Label4.Text = "";
}
}
运行后,label的内容总是显示“此用户已存在”这是为什么啊?
label的text是空的,我就是把forecolore改成了“red”,应该没有什么问题吧~
|