Search code examples
c#oledbdbf

C# OLEDB DBF Querying issue with codepage invalid data


Hello I'm trying to connect to a DBF and query it.

I use the following connectionstring:

 string s = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(this.ShapePathFileName) + "\\;Extended Properties=dBASE IV;User ID=Admin;Password=;";

Then I want to fill a datatable it the result:

oleDbDataAdapter = new OleDbDataAdapter(selectCommand);
((DbDataAdapter)oleDbDataAdapter).Fill(dataTable);

But I've in the results values like this: "ÒoþÚ"

but in the file I've this: "ãoçé"

also if in the SQL statement I've WHERE name like '%é' I get no results, but with WHERE name like '%Ú' I've results

any ideas how to fix this?


Solution

  • Try adding

    Collate=YourDbCollation
    

    or

    CodePage=YourCodePage
    

    in the query string.

    Even better than that, try donwloading an usign

    VIsual FoxPro OleDB Provider

    You have lot of samples of how the new query string should look like:

    Visual Fox Pro Connection Strings