ASP.Net 2.0 Access Database connection string
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
<connectionStrings> <add name="accessConStr" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|db1.mdb" providerName="System.Data.OleDb"> </add> </connectionStrings>
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.