Trying to do some work on reading and writing DBF files, and I found this example: http://www.aspcode.net/reading-dbf-files-in-c
System.Data.Odbc.OdbcConnection oConn = new System.Data.Odbc.OdbcConnection(); oConn.ConnectionString = @"Driver={Microsoft dBase Driver (*.dbf)};SourceType=DBF;SourceDB=D:\databases\;Exclusive=No; Collate=Machine;NULL=NO;DELETED=NO;BACKGROUNDFETCH=NO;"; oConn.Open(); System.Data.Odbc.OdbcCommand oCmd = oConn.CreateCommand(); oCmd.CommandText = @"SELECT * FROM D:\databases\thefile.dbf" ; DataTable dt = new DataTable(); dt.Load(oCmd.ExecuteReader()); oConn.Close(); dataGridView1.DataSource = dt;
Only problem is that it does not work if the file or folder name has a dash (-) in it. Is there a way to make this query work with dashes in names?
eg. DBF File: C:\Temp\bowlpos\07-10\01-07-10.DBF
source share