If the program is crashing, it has to be throwing an exception...
to get the error message try this:
Private Sub Form1_Load(...)
Dim dbCon As OleDbConnection
Dim dbCmd As OleDbCommand
Dim dbRead As OleDbDataReader
try
dbCon = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\My.accdb;Persist Security Info=False;")
dbCon.Open()
catch ex as exception
msgBox(ex.Message, vbOkOnly, "Error During dbCon.Open()")
return
End Try
dbCmd = New OleDbCommand("SELECT * FROM CITY", dbCon)
dbRead = dbCmd.ExecuteReader
Do While dbRead.Read
MsgBox(dbRead(1))
Loop
End Sub
My gut feeling is that this is a connection string issue
try this:
Dim DBName as String = "c:\path_of_db\dbname.dbext"
Dim ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBName & ";User ID=Admin;Password="
dbCon = New OleDbConnection(ConString)