Tuesday, May 20, 2008

connection string for Access database in .net

MS Access ODBC connection strings

Standard Security:
"Driver={MicrosoftAccessDriver(*.mdb)};DBQ=C:\App1\Your_Database_Name.mdb;
Uid=Your_Username;Pwd=Your_Password;"

Workgroup:
"Driver={Microsoft Access Driver (*.mdb)};
Dbq=C:\App1\Your_Database_Name.mdb; SystemDB=C:\App1\Your_Database_Name.mdw;"

Exclusive:
"Driver={Microsoft Access Driver (*.mdb)};
DBQ=C:\App1\Your_Database_Name.mdb; Exclusive=1; Uid=Your_Username; Pwd=Your_Password;"

MS Access OLE DB & OleDbConnection (.NET framework) connection strings
Open connection to Access database:

"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\App1\Your_Database_Name.mdb; User Id=admin; Password="

Open connection to Access database using Workgroup (System database):
"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:System
Database=c:\App1\Your_System_Database_Name.mdw"

Open connection to password protected Access database:
"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\App1\Your_Database_Name.mdb; Jet OLEDB:Database Password=Your_Password"

Open connection to Access database located on a network share:
"Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=\\Server_Name\Share_Name\Share_Path\Your_Database_Name.mdb"

Open connection to Access database located on a remote server:
"Provider=MS Remote; Remote Server=http://Your-Remote-Server-IP; Remote
Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\App1\Your_Database_Name.mdb"

No comments: