1

I am developing an application to recover data from a DBF file.

I did research on the Internet that sent me to this link : enter link description here

I applied this code but nothing helps it doesn't work :/

            string constr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Test\users.dbf;Extended Properties=dBASE IV;User ID=;Password=MyPassword;";
            using (OleDbConnection con = new OleDbConnection(constr))
            {
                
                var sql = "select * from users.dbf";
                OleDbCommand cmd = new OleDbCommand(sql, con);
                con.Open();
                DataSet ds = new DataSet(); ;
                OleDbDataAdapter da = new OleDbDataAdapter(cmd);
                da.Fill(ds);
            }

I pass this code in a Try and Catch and it returns me this error: Unable to start your application. The workgroup information file is missing or opened exclusively by another user. the error is caused when trying to open the connection. However the file is neither opened nor used by anyone else.

thank you in advance ;)

Laura Destier
  • 41
  • 3
  • 11
  • 1
    The Jet only works with Office 2003 or earlier. For new files you need to use ACE instead of jet. – jdweng Jun 23 '20 at 14:05

1 Answers1

1

Try to remove the file name in the connection string. According to the documentation, The "Data Source" property should only contain the path.

            string constr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\Test;Extended Properties=dBASE IV;User ID=;Password=MyPassword;";
GRFRM
  • 236
  • 1
  • 6
  • Hello, thank you for your response it works well however I was asked to be able to read a dbf file with a password and when I restart the program it returns the same error as at the beginning. i did some research but no way to figure out how to add this password – Laura Destier Jun 24 '20 at 06:31
  • I have just realized that for the dbf without password that one cannot fill the DataSet and returns me this error : The Microsoft Jet database engine could not find the object 'users'. Make sure the object exists and that you have entered its name and path correctly. – Laura Destier Jun 24 '20 at 11:06
  • You get the " The workgroup information file is missing or opened exclusively by another user" error because your connection string has no user defined: "...;User ID=;Password=MyPassword;". The "User ID" property is empty. Do you know the account/password for this file ? – GRFRM Jun 25 '20 at 12:42