ASP.Net 2.0 Access Database connection string

Updated on 03 Apr 2012,
Published on 07 Jul 2008

In ASP.Net 2.0, Microsoft Access database connection string can be declared inside the connectionstrings section of web.config file. In ASP.Net 2.0 Microsoft has introduced a new feature of directories for different types of resources. In ASP.Net 2.0 there is a default directory App_Data to store the database files. You can store the MS Access database file inside the App_Data directory that can be useful for providing its relative path in the connection string for Access Database. MS Access database supports the OLEDB drivers to connect with ASP.Net web applications. Here Oledb stands for Object Linking and Embedding Database. ASP.Net consists of a provider class for OLEDB under System.Data.Oledb namespace that allows you to connect the MS Access database with ASP.Net web application.

Example of ASP.Net 2.0 Access Database Connection String

  <add name="accessConStr"
       connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|db1.mdb"

name attribute of connectionstrings add element contains the name as accessConStr for the connection string.  

connectionString attribute contains the connection string format supported by Oledb drivers. |DataDirectory| is used in the above of connection string to connect the MS Access Database placed inside the App_Data directory. By Default |DataDirectory| maps the path of database file placed inside the default App_Data directory. After |DataDirectory| add up the name of MS Access Database filename as shown in above example.

providerName attribute contains the name of the Namespace of ASP.Net 2.0 that will provide the methods and functions for Data Access while coding.

Continue to next tutorial: ASP.Net 2.0 SQL Server database connection string to learn about the connection string for connecting to SQL Database.

7 Responses to "ASP.Net 2.0 Access Database connection string"
thanks, just what I was looking for...
sorry, i'm a newby in Access what kind of class do i have to use to open the connection?
Ngo Thanh Long
Great! it helped me alot, thanks.
thank you very much that's what i need
hey thanks.. Exactly what a newbie looks for.
Thanks a ton.
Thanks. This is exactly i was looking for. Thanks Again!
Leave a Comment
* required
* required
* will not be published
* optional
* hint:
  • Subscribe via Email