Come utilizzare un oggetto OleDbDataAdapter




aGGIUNGERE NELLE REFERENZE ADODB nel progetto


Imports System.Data.OleDb


Public Class Form1


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyRs As New ADODB.Recordset()
Dim MyCn As New ADODB.Connection()
MyCn.Open("Provider=Microsoft.jet.oledb.4.0;data source=C:\Procedure\Borse Rete\DataBase\aRCHIVI.MDB")

MyRs.Open("Select * from Domande2007", MyCn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic)

Do While Not MyRs.EOF
Debug.Print(MyRs.Fields("mATRICOLA").Value & " - " & MyRs.Fields("SEDE").Value)
MyRs.MoveNext()

Loop


'Create and fill the DataSet from the Recordset. Populate the grid from the DataSet.

Dim myDA As OleDbDataAdapter = New OleDbDataAdapter()
Dim myDS As DataSet = New DataSet()
myDA.Fill(myDS, MyRs, "MyTable")
DataGrid1.DataSource = myDS.Tables(0)

'Close ADODB objects.

'Note that the OleDbDataAdapter.Fill overload that takes

'a DataTable and an ADO object implicitly calls Close on

'the ADO object when the Fill operation is complete.


MyRs = Nothing
MyCn.Close()
MyCn = Nothing

End Sub
End Class










( comeutilizzareunoggettooledbdataadapter.html )- by Paolo Puglisi - Modifica del 17/12/2023