- 博客(0)
- 资源 (2)
- 收藏
- 关注
c#语言登录界面代码一篇
这是一篇菜鸟级的登录界面设计方案.
在VS2005.NET平台下用C#和Access实现用户登录界面的窗体应用程序
string conStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\db.mdb";
OleDbConnection con = new OleDbConnection(conStr);
con.Open();
string cmdStr = "select * from users where userName='" + this.userNameTbx.Text + "' and userPassword='" + this.pswTbx.Text + "'";
OleDbCommand cmd = new OleDbCommand(cmdStr, con);
OleDbDataReader reader = cmd.ExecuteReader();
if (reader.Read()) //如果找到用户信息,说明登录成功
{
MainForm newForm = new MainForm();
newForm.Show(); //弹出主窗体
this.Hide(); //隐藏用户登录窗体
}
else
{
MessageBox.Show("用户名或密码错误!");
}
reader.Close();
cmd.Connection.Close();
con.Close();
}
private void cancleBtn_Click(object sender, EventArgs e)
{
this.Close();
}
2010-05-10
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人