简单易懂方便coppy
SqlCommand com = new SqlCommand(cmd, conConnection); SqlDataReader reader = com.ExecuteReader();
while (reader.Read())//从数据库读取用户信息
{
User = reader["用户名"].ToString();
Pwd = reader["密码"].ToString();
if (User.Trim () == textBox1.Text & Pwd.Trim () == textBox2.Text) {
flagshow = true; //用户名存在于数据库,则为true
}
}
reader.Close();
conConnection.Close();
if (flagshow == true)
{
showMainForm();//用户存在,返回登录界面
}
else
{
MessageBox.Show("用户不存在或密码错误!", "提示");
return;
}
}
private void showMainForm()//登录成功,显示主界面
{
this.Close();
Form1 f1 = new Form1();
http://www.77cn.com.cnbel1.Visible = false;
http://www.77cn.com.cnbel3.Visible = false;
f1.linkLabel1.Visible = false;
f1.linkLabel2.Visible = false;
http://www.77cn.com.cnbel2.Visible = true;
http://www.77cn.com.cnbel2.Text = "欢迎你," + textBox1 .Text ;
f1.Show();
}
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库源码C#登录注册小程序源码(5)在线全文阅读。
相关推荐: