I'm writing a VB NET program to read dBase .dbf files using the OleDbReader. When the filename contains an underscore, the OleDbDataReader gives a file not found error, whereas the same file without the underscore in the name works just fine.
Some sample code of what I'm doing:
Dim dBaseConnection As OleDbConnection
Dim dBaseCommand As OleDbCommand
Dim dBaseDataReader As OleDbDataReader
Dim schemaTable As DataTable
Dim x, y, z
Dim Builder As New OleDbConnectionStringBuilder With
{
.DataSource = IO.Path.GetDirectoryName(filename),
.Provider = "Microsoft.Jet.OLEDB.4.0"
}
Builder.Add("Extended Properties", "dBase III")
dBaseConnection = New OleDbConnection With {.ConnectionString = Builder.ConnectionString}
dBaseConnection.Open()
dBaseCommand = New OleDbCommand("SELECT * FROM " & filename, dBaseConnection)
dBaseDataReader = dBaseCommand.ExecuteReader(CommandBehavior.SequentialAccess)
schemaTable = dBaseDataReader.GetSchemaTable()
While dBaseDataReader.Read And Not _abort
x = Val(dBaseDataReader("x").ToString)
y = Val(dBaseDataReader("y").ToString)
z = Val(dBaseDataReader("z").ToString)
'do other stuff here
End While
Does anyone know whether an underscore is a forbidden symbol for a dbf filename? Or is this some sort of bug?
In this case the filename was "c:\temp\test_info.dbf".