I am trying to connect to a DBF (HISTORY.DBF
) that has a linked SMT file (HISTORY.SMT
). I have multiple DBF files and I can connect to all of them except the ones with SMT files.
Looking at the header information of the DBFs suggests it is a Clipper (E5 Header) format DBF which reads fine using the connection code below for most files, but once I try to read a file with an associated SMT it fails with the fault:
External table is not in the expected format
My Code is as below
Dim dsDataSet As New DataSet
Dim ConnectionString As String
Dim daDataAdapter As OleDb.OleDbDataAdapter
Dim dBaseConnection As New System.Data.OleDb.OleDbConnection
Dim strFilePath As String = gloStrPath & "data"
Dim strDBF As String = "HISTORY.DBF"
Try
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFilePath & ";Extended Properties=dBase III;"
dBaseConnection = New System.Data.OleDb.OleDbConnection(ConnectionString)
If dBaseConnection.State = 0 Then dBaseConnection.Open()
Catch ex As Exception
MsgBox(ex.Message, 16, "Error")
End Try
Try
daDataAdapter = New OleDb.OleDbDataAdapter("select * from " & strDBF, dBaseConnection)
daDataAdapter.Fill(dsDataSet, "Name")
Catch ex As Exception
MsgBox(ex.Message, 16, "Error")
End Try
Can anyone offer any insight into what I am doing wrong or what I am missing?