Getting “System.InvalidOperationException” When trying to open and OLE DB connection

I'm trying to connect to a Visual FoxPro Database that I downloaded for testing purposees using OLE DB, this is my code:

private void ReadMyData() {
     String dbProvider = "Provider=.NET Framework Data Provider for OLE DB;";
     String dbSource = "Data Source=VFPOLEDB.C:\\USERS\\X\\DESKTOP\\LOG;";
     String connectionString = dbProvider + dbSource;
     OleDbConnection FPDBConn = new OleDbConnection(connectionString);

     OleDbCommand FPDBCmd;
     string sql = null;

     sql = "Select * from clogbook";

     try {
         FPDBCmd = new OleDbCommand(sql, FPDBConn);
         OleDbDataReader FPDBReader = FPDBCmd.ExecuteReader();
         while (FPDBReader.Read()) {
             Debug.Write(FPDBReader.GetInt32(0) + ", " + FPDBReader.GetString(1));
     } catch (Exception ex)
           Debug.Write("Can not open connection ! " + ex);

The problem is I'm getting "System.InvalidOperationException: The '.NET Framework Data Provider for OLE DB' provider is not registered on the local machine."

I was googling about it and came across this msdn page that says that the exception "InvalidOperationException" has the condition "The connection is already open." Which I don't think is happenning in this case.

How can I get this to work?

PS: Accepting different suggestions to make this connection.

edit delete
are you sure?
asked Vítor Martins

0 answers

Post an answer but please log in first

Post Answer
  1. Please log in to post answer

Similar Questions

Tagsfor this question

Forumall questions