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

[复制链接]
查看11 | 回复4 | 2009-3-11 09:42:49 | 显示全部楼层 |阅读模式
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”,应该没有什么问题吧~

回复

使用道具 举报

千问 | 2009-3-11 09:42:49 | 显示全部楼层
你先用select count(*) from systemuser where userName='用户名'试试,如果查询结果大于0,当然“此用户已存在”另外,你Label初始值是什么啊,如果是“此用户已存在”也会有问题...
回复

使用道具 举报

千问 | 2009-3-11 09:42:49 | 显示全部楼层
可以去掉的...
回复

使用道具 举报

千问 | 2009-3-11 09:42:49 | 显示全部楼层
你看看count的值是什么啊...
回复

使用道具 举报

千问 | 2009-3-11 09:42:49 | 显示全部楼层
label默认是显示得 要控制 当然是判断当前是否要显示 label属性里有是否显示label得 属性...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行