The
Connection String for
MS Access can be set as ;
private constr =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdbfile.mdb;
Jet OLEDB:Database Password=yourpassword;";
And the
C# code to connect to
MS Access database ;
public bool OpenConnection()
{
OleDbConnection con; con = new OleDbConnection(constr);
if (con.State != ConnectionState.Open)
{
try
{
con.Open(); return true;
}
catch (Exception) { return false; }
}
else return false;
}
C# Access Connection String OLE DB OleDbConnection password field is the password you set up in access database.
3 comments:
private String constr =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdbfile.mdb;
Jet OLEDB:Database Password=yourpassword;";
This was really really helpful, thankzzz!!
try this simple code
string connetionString = null;
OleDbConnection cnn ;
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=yourdatabasename.mdb;";
cnn = new OleDbConnection(connetionString);
try
{
cnn.Open();
MessageBox.Show ("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
curos
Post a Comment