ADO.NET ODBC Connection

In the .NET Framework, the OdbcConnection class provides support for the ODBC Data Provider, allowing VB.Net applications to connect to databases through the ODBC interface. To establish a connection, an instance of the OdbcConnection class is created, which takes a connection string as an argument and passes it to the constructor.

OdbcConnection

Once the OdbcConnection instance is created and the connection is established, SQL commands can be executed with the help of the Connection Object. These SQL commands enable data retrieval, manipulation, or other operations within the connected database.

After the database activities are completed, it is important to close the connection and release the associated resources. In the case of SqlConnection (which is not applicable for OdbcConnection), the Close() method is used to close the database connection. This method also rolls back any pending transactions and releases the connection from the database connected through the ODBC Data Provider.

It's worth noting that the Close() method mentioned above is specific to the SqlConnection class, and does not apply to the OdbcConnection class. Instead, the OdbcConnection class provides its own Close() method to close the connection and release resources.

Full Source VB.NET
Imports System.Data.Odbc Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim connetionString As String Dim cnn As OdbcConnection connetionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=yourdatabasename.mdb;" cnn = New OdbcConnection(connetionString) Try cnn.Open() MsgBox("Connection Open ! ") cnn.Close() Catch ex As Exception MsgBox("Can not open connection ! ") End Try End Sub End Class

You have to provide the necessary informations to the Connection String.

connetionString = "Driver = {Microsoft Access Driver (*.mdb)}; DBQ = yourdatabasename.mdb;"

From the above statement replace yourdatabasename.mdb to the actual names.