I am creating a 32bit app on an old XP machine, this app will run on Win7 or later as well.
so I am trying to test for what connection string will work. Such as:
Private Function test_ace_or_jet(ByVal mdb_path As String) As String
Dim connString As String
Dim dbMaintPort As OleDb.OleDbConnection
connString = ""
Try
connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & mdb_path
dbMaintPort = New OleDb.OleDbConnection(connString)
dbMaintPort.Open()
dbMaintPort.Close()
MsgBox("1 was found")
Catch ex As Exception
MsgBox("Could not open 1" & vbCrLf & vbCrLf & ex.Message)
Try
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mdb_path
dbMaintPort = New OleDb.OleDbConnection(connString)
dbMaintPort.Open()
dbMaintPort.Close()
MsgBox("2 was found")
Catch ex2 As Exception
connString = ""
MsgBox("Could not open 2" & vbCrLf & vbCrLf & ex2.Message)
End Try
End Try
test_ace_or_jet = connString
End Function
However the issue that I've found is that on the XP machine, the first connection string does not fail. It does not have ACE installed at all.
How can I test whether to use one or the other? Am I able to get the above function to give me the correct connection string?