This sample refers to the System.Data.OleDb Class Library namespaces and NWIND.mdb (access database).
Imports System.Data.OleDb
Dim strConn As String
Dim strSQL As String
Dim Conn As OleDbConnection
Dim objDA As OleDbDataAdapter
Dim objDS As New DataSet()
Try 'MAKE SURE TO CHANGE THE PATH OF NWIND.mdb AS PER ON YOUR MACHINE.
'Build the Connection strings.
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND.mdb"
'Pass the Connection string to OleDbConnection object.
Conn = New OleDbConnection(strConn)
'Initialize the OleDbDataAdapter with SQL and Connection string,
'and then use the OleDbAdapter to fill the DataSet with data.
objDA = New OleDbDataAdapter(strSQL, Conn)
objDA.Fill(objDS, "Employees")
'Bind the DataSet to DataGrid.
DataGrid1.SetDataBinding(objDS, "Employees")
Catch Excep As System.Exception
MessageBox.Show(Excep.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.