How to use record set in dotnet2005
The first step to add a reference to the ADO library. You can add reference to the ADO library by using Project->Add Reference menu item and then select COM tab seelct Microsoft ActiveX data Objects 2.7 Library.
After adding this reference, you'll see the ADODB namespace is added to your project
Projects->Reference->ADODB
Import namespace
-
Imports System.Data
-
Imports System.Data.OleDb
-
Imports ADODB
-
-
-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
' Create a connection string
-
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\Northwind.mdb"
-
Dim sql As String = "SELECT CustomerId, CompanyName, ContactName From Customers"
-
-
Dim rs As _Recordset = conn.Execute(sql)
-
' Create dataset and data adpater objects
-
Dim ds As DataSet = New DataSet("Recordset")
-
Dim da As OleDbDataAdapter = New OleDbDataAdapter
-
' Call data adapter's Fill method to fill data from ADO
-
' Recordset to the dataset
-
da.Fill(ds, rs, "Customers")
-
' Now use dataset
-
DataGrid1.DataSource = ds.DefaultViewManager
-
End Sub
-
-
-
hope it work