Hello all,
I need some help from you to translate VB.NET code to VBA. This is the code I would like to have help with:
Dim con As New OleDb.OleDbConnection
Dim com As New OleDb.OleDbCommand
Dim dr As Data.OleDb.OleDbDataReader
con.Open()
com.Connection = con
com.CommandText = "SELECT ID, NAME, ANZDB FROM BSTCNTOF.DBF" _
& " ORDER BY ID"
dr = com.ExecuteReader()
If con.State = System.Data.ConnectionState.Open Then
While dr.Read
If dr("ANZDB") > 0 Then
MsgBox("Name: " & dr("NAME"))
MsgBox("ID: " & dr("ID"))
End If
End While
Else
MessageBox.Show("Can not connect to Data base", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
con.Close()
Cheers Steff
I need some help from you to translate VB.NET code to VBA. This is the code I would like to have help with:
Dim con As New OleDb.OleDbConnection
Dim com As New OleDb.OleDbCommand
Dim dr As Data.OleDb.OleDbDataReader
con.Open()
com.Connection = con
com.CommandText = "SELECT ID, NAME, ANZDB FROM BSTCNTOF.DBF" _
& " ORDER BY ID"
dr = com.ExecuteReader()
If con.State = System.Data.ConnectionState.Open Then
While dr.Read
If dr("ANZDB") > 0 Then
MsgBox("Name: " & dr("NAME"))
MsgBox("ID: " & dr("ID"))
End If
End While
Else
MessageBox.Show("Can not connect to Data base", "", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
con.Close()
Cheers Steff