C# 中怎么制作登陆界面 用的ACCESS数据库
小弟刚接触C#,现在需要做一登陆界面,用的ACCESS数据库,请问怎么制作登陆页面啊,
我自己的方法是SQL语言查询ID ,然后判断password是否相等
代码如下:
private void Button1_Click(object sender, System.EventArgs e)
{
if((TextBox1.Text!="")&&(TextBox2.Text!=""))
{
string connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Server.MapPath(@".\db\db1.mdb")+";Mode=Share Deny None;Persist Security Info=False";OleDbConnection conn=new OleDbConnection(connstr);
conn.Open();
string sql="SELECT id FROM id WHERE id='"+TextBox1.Text+"";
OleDbCommand cmd=new OleDbCommand(sql,conn);
OleDbDataReader dr=cmd.ExecuteReader();
if(dr.Read()==true)
{
if(dr.GetValue(0).ToString()==TextBox2.Text)
{MsgBox("OK");
}
else
{MsgBox("Wrong");
}
}
dr.Close();
}
}
}
//MsgBox类略
但是一直有问题 不能解决 请高人指点啊
PS:登陆用的库名为id 属性有id和password