The ASP.NET OleDbConnection instance takes Connection String as argument and pass the value to the Constructor statement. An instance of the ASP.NET OleDbConnection class is supported the OLEDB Data Provider .
vb.net Dim connectionString As String
Dim connection As OleDbConnection
connectionString = ConfigurationManager.ConnectionStrings("OLEDbConnection").ToString
connection = New OleDbConnection(connectionString)
string connectionString = ConfigurationManager.ConnectionStrings["OLEDbConnection"].ToString();OleDbConnection connection = new OleDbConnection(connectionString);
When the connection is established betweenASP.NET application and the specified Data Source, SQL Commands will execute with the help of the Command Object and retrieve or manipulate data in the database. Once the Database activities is over Connection should be closed and release from the data source resources .
The Close() method in the OleDbConnection class is used to close the Database Connection. The Close method Rolls Back any pending transactions and releases the Connection from the Database connected by the OLEDB Data Provider.
Copy and paste the following content into your web.config file and provide the parameter values.
web.config
The following ASP.NET program trying to establish connection to a .mdb file and display the message in Label control.
Default.aspx
Untitled Page
Click the following links to see full source code
Advertisement