Here's some code I used, works perfect for me!
I'm using Microsoft Access 2007 and Visual Studio 2010 Ultimate on Windows 7 Ultimate x64.
You'll need to change the connection string and path to the actual database file
Code:
Add this in your Using Section:
using System.Data.OleDb;
string ConnStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=G:\\MedDesk\\Login.accdb;";
OleDbConnection MyConn = new OleDbConnection(ConnStr);
try
{
MyConn.Open();
string StrCmd = "SELECT User, Pass FROM LoginTable WHERE User='"+user.Text + "' and Pass='" + pass.Password + "'";
OleDbCommand Cmd = new OleDbCommand(StrCmd, MyConn); ;
OleDbDataReader ObjReader = Cmd.ExecuteReader();
if (ObjReader != null)
{
new MainWindow().Show();
}
ObjReader.Close();
MyConn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}