none
C# DBF handling, Office 2007 environment RRS feed

  • Question

  • Hi

    I have an existing app which needs to read the data in some old DBF files. I have found that the connector no longer works when i moved to my new windows 7 x64 pc with office 2007.

    Previously on my old pc, at some stage office 2003 was installed that supported DBFs, hence i assume the connector.

    => What would be good is some connection example for DBF support which should work in most cases with a PC with office 2007 or later ?

    I would prefer that my little utility does not need some extra package install.

    Below is the existing code.

     string connstr = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=dBase IV", path);
    
    
    
     string query = String.Format("SELECT * FROM {0}", table);
    
    
    
     OleDbConnection conn = new OleDbConnection(connstr);
    
    
    
     conn.Open();
    
    
    
     OleDbCommand cmd = new OleDbCommand(query, conn);
    
    
    
     OleDbDataReader reader = cmd.ExecuteReader();
    
    
    
     DataTable results = new DataTable(table);
    
    
    
     DataTable fields = reader.GetSchemaTable();
    
    
    
     foreach (DataRow field in fields.Rows)
    
    
    
     {

     

    Many thanks

    Thursday, June 10, 2010 8:19 AM

Answers

  • You will need to compile your app so that it runs as 32-bit in a 64-bit environment. It's the Platform option (Build...Configuration Manager) and it should be changed to x86. You may need to add this option first if it isn't already present.

    Paul ~~~~ Microsoft MVP (Visual Basic)
    Thursday, June 10, 2010 8:05 PM

All replies

  • You will need to compile your app so that it runs as 32-bit in a 64-bit environment. It's the Platform option (Build...Configuration Manager) and it should be changed to x86. You may need to add this option first if it isn't already present.

    Paul ~~~~ Microsoft MVP (Visual Basic)
    Thursday, June 10, 2010 8:05 PM
  • Brillant, worked a treat!
    Friday, June 11, 2010 2:23 AM