1

file dbf: C:\myTable.dbf; code:

var file = @" C:\myTable.dbf";
var connectionString = @"Provider=vfpoledb;Data Source=" + file + ";Collating Sequence=machine;";
OdbcConnection conn = new OdbcConnection(connectionString);
conn.Open();

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
2
  • Something seems wrong in your connection string. Look at these examples - ODBC - connectionstrings.com/microsoft-visual-foxpro-odbc-driver Commented Sep 26, 2013 at 15:21
  • I'm pretty sure "Collating Sequence" isn't the right string. Try just "Collate" there. Commented Sep 26, 2013 at 20:50

1 Answer 1

1

Can you Please try changing connection string provider

try { string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\ZIP.DBF;Extended Properties=dBase IV"; OleDbConnection conn = new OleDbConnection ( conString ); command = conn . CreateCommand ( );

     // create the DataSet
     DataSet ds = new DataSet ( );
     dataGridView1 . DataSource = null;

     // open the connection
     conn . Open ( );
     string commandString = "Select * from  ZIP.DBF";
     // run the query
     command . CommandText = commandString;
     OleDbDataAdapter adapter = new OleDbDataAdapter ( command );
     adapter . Fill ( ds );

     // close the connection
     conn . Close ( );

     // set the grid's data source
     dataGridView1 . DataSource = ds . Tables [ 0 ];
     }
 catch ( Exception ex)
     {
     MessageBox . Show (  ex . Message );

     }      
Sign up to request clarification or add additional context in comments.

2 Comments

debug: conn.Open() --> Error: C:\myTable.dbf is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
you can put your dbf file on the other location than the c drive as on c drive have some permission issue also. and change the path in the connection string. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.