G
Guest
I have a VB2005 application that has the need to read FoxPro 2.5 DBF/CDX
files. I have the code (below) that opens the connection, but there are never
any records, nor errors, reported... Can anyone tell me what I'm doing
wrong?
The ConnectionString resolves to "Provider=VFPOLEDB.1;Data
Source=C:\test\REVFILEF.DBF;Mode=Read|Share Deny None;Collating
Sequence=MACHINE"
Private Function DoDBFProcess(byVal InputFileName as String) As Long
Dim RecordsExported As Long = 0, RowNumber As Long = 0
Dim Conn As New OleDb.OleDbConnection
Dim Cmd As New OleDb.OleDbCommand
Dim Adapt As New OleDb.OleDbDataAdapter
Dim Read As OleDb.OleDbDataReader
Try
Conn.ConnectionString = "Provider=VFPOLEDB.1;Data Source=" &
InputFileName & ";Mode=Read|Share Deny None;Collating Sequence=MACHINE"
Conn.Open()
Cmd.CommandType = CommandType.TableDirect
Cmd.Connection = Conn
Read = Cmd.ExecuteReader
While Read.HasRows = True
Read.Read()
RowNumber += 1
'<Does more processing here...>
End While
Catch ex1 As Exception
Msg += ex1.Message
MsgBox(Msg)
Finally
Conn.Close()
Conn = Nothing
End Try
Return RecordsExported
End Function
files. I have the code (below) that opens the connection, but there are never
any records, nor errors, reported... Can anyone tell me what I'm doing
wrong?
The ConnectionString resolves to "Provider=VFPOLEDB.1;Data
Source=C:\test\REVFILEF.DBF;Mode=Read|Share Deny None;Collating
Sequence=MACHINE"
Private Function DoDBFProcess(byVal InputFileName as String) As Long
Dim RecordsExported As Long = 0, RowNumber As Long = 0
Dim Conn As New OleDb.OleDbConnection
Dim Cmd As New OleDb.OleDbCommand
Dim Adapt As New OleDb.OleDbDataAdapter
Dim Read As OleDb.OleDbDataReader
Try
Conn.ConnectionString = "Provider=VFPOLEDB.1;Data Source=" &
InputFileName & ";Mode=Read|Share Deny None;Collating Sequence=MACHINE"
Conn.Open()
Cmd.CommandType = CommandType.TableDirect
Cmd.Connection = Conn
Read = Cmd.ExecuteReader
While Read.HasRows = True
Read.Read()
RowNumber += 1
'<Does more processing here...>
End While
Catch ex1 As Exception
Msg += ex1.Message
MsgBox(Msg)
Finally
Conn.Close()
Conn = Nothing
End Try
Return RecordsExported
End Function