Connection.Open invalid operation exception using Jet OLEDB and Paradox in .net project
I have a large collection of small databases that open in Access. I am trying to open them in a vb.net application (.net framework 4.7.2) with this connection string (and variations for the many directories that contain the other database files): "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=R:\ConversionInputs\CONVBIN-210-
Public Class Form1
Private ReadOnly mstrConnectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended properties=Paradox 7.x;"
Private Sub ButtonExport_Click(sender As Object, e As EventArgs) Handles ButtonExport.Click
Dim patients = IO.Directory.GetFiles(Me.tbImages.Text, "*.db", IO.SearchOption.AllDirectories)
lblResult.Text = $"Found {patients.Length} patient directories in {Me.tbImages.Text}."
For Each patient As String In patients
If Not patient.ToLower.Contains("patient") Then Continue For
If patient.Contains("PatientList") Then Continue For
Using oledbCon As New System.Data.OleDb.OleDbConnection(String.Format(mstrConnectString, IO.Path.GetDirectoryName(patient)))
Try
oledbCon.Open()
If oledbCon.State = ConnectionState.Open Then
lblResult.Text = $"Opened {patient}."
Else
lblResult.Text = $"Failed to open {patient}. State is {oledbCon.State}."
End If
Catch ex As Exception
lblResult.Text = $"Exception in attempt to open {patient}. State is {oledbCon.State}. Exception is {ex.Message}"
End Try
End Using
Next
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Me.FolderBrowserDialog1.ShowDialog() = DialogResult.OK Then Me.tbImages.Text = Me.FolderBrowserDialog1.SelectedPath
End Sub
End Class
1 answer
I just had to step back from .net framework 4.7.x to 3.5. Apparently, the more recent .net framework versions don't support paradox .db files well.