.net中的label中的文字怎么总是显示

来源:百度知道 编辑:UC知道 时间:2024/09/23 16:28:01
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.qu

你先用select count(*) from systemuser where userName='用户名'
试试,如果查询结果大于0,当然“此用户已存在”
另外,你Label初始值是什么啊,如果是“此用户已存在”也会有问题

label默认是显示得 要控制 当然是 判断当前是否要显示 label 属性里有是否显示label得 属性

你看看count的值是什么啊

可以去掉的