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.
connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source= |DataDirectory|db1.mdb"
</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.
Be the first to rate this post
Tags: asp.net 2.0, ado.net, asp.net access database connection string, asp.net connectionstring, asp.net web.config, asp.net database connection, asp.net sql connection string, asp.net access connection string, web.config connectionstrings, web.config configuration, odbc microsoft access drivers, oledb connection string, app_data
10/11/2008 3:20:00 AM