Imports ADOX
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
Dim DataBaseName As String = My.Application.Info.DirectoryPath & "\dbListino.mdb"
Dim dr As OleDbDataReader
Dim connessione As ADOX.Catalog = New ADOX.Catalog 'crea un nuovo oggetto connessione di tipo ADOX.Catalog
Dim archivio As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + DataBaseName + ";" + "Jet OLEDB:Engine Type=5") 'Crea un nuovo oggetto archivio di tipo OleDbConnection
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
CaricareTabelleDatabaseDataGridView() 'Funzione che carica i dati nell'DataGridView
End Sub
Private Sub CaricareTabelleDatabaseDataGridView()
Try
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
archivio.Open()
da = New OleDbDataAdapter("SELECT * FROM tbListino ", archivio)
da.Fill(dt)
DataGridView1.DataSource = dt.DefaultView
archivio.Close()
Catch
archivio.Close()
MsgBox("Errore contatore Record *")
End Try
End Sub
End Class