.net中的label中的文字怎么总是显示 10
protectedvoidbtn_add_into_data_xitongyonghu_Click(objectsender,EventArgse){OleDbConne...
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”,应该没有什么问题吧~ 展开
{
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”,应该没有什么问题吧~ 展开
4个回答
展开全部
label默认是显示得 要控制 当然是 判断当前是否要显示 label 属性里有是否显示label得 属性
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你看看count的值是什么啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以去掉的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询