' esempio su CreaReport.exe
Imports System.Data.OleDb Public Class Ole_DB Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i As Long Dim oledbCmd As OleDbCommand Dim sql As String sql = "Select Santo, Nome from Santi order by Nome" Try oledbCmd = New OleDbCommand(sql, Dbaz) Dim oledbReader As OleDbDataReader = oledbCmd.ExecuteReader() While oledbReader.Read i = MsgBox(oledbReader.Item("Santo") & " - " & oledbReader.Item("Nome"), MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton1) ' oppure i = MsgBox(oledbReader.Item(0) & " - " & oledbReader.Item(1), MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton1) If i = vbNo Then Me.Close() End If End While oledbReader.Close() oledbCmd.Dispose() Catch ex As Exception MsgBox("Can not open connection ! ") End Try End Sub Private Sub Form5_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If ApriDatabase("D:\Procedure\CalendarioILVO\Database - ILVO\appunti.mdb") = False Then MsgBox("Errore COnnessione", MsgBoxStyle.Critical) End If End Sub End Class |