try
{
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Users\jay.desai\Documents\Visual Studio 2008\Projects\Jahoo Sign in form!\Jahoo Sign in form!\Registration_form.mdb");
con.Open();
OleDbCommand cmd = new OleDbCommand("select * from Login where Username='"+txtlognUsrnm.Text+"' and Password='"+txtlognpswrd+"'", con);
OleDbDataReader dr = cmd.ExecuteReader();
if(dr.Read() == true)
{
MessageBox.Show("Login Successful");
}
else
{
MessageBox.Show("Invalid Credentials, Please Re-Enter");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
我已创建一个登录表单,并在Microsoft Access一个表中包含用户名和密码fields.when我点击登录按钮,它总是显示其他消息,虽然用户名和密码是相同表。访问数据库的登录表单
你有什么问题吗? – Raptor
也许实际上在你的查询字符串中传递密码? 'txtlognpswrd'应该是'txtlognpswrd.Text'。 **但是** - 请学习并使用参数化查询来防止SQL注入攻击。 – Tim