ADO .NET Exclusive connection to MDB file is broken after last Office Update

  • Thread starter Thread starter Iñigo Panera
  • Start date Start date
I

Iñigo Panera

Guest
Hi every one,

We have a mature Software build with C# + Windows Forms that uses ADO .NET to connect an Access MDB file. It has been working well for years.
The problem is that after de last Office Updates we are getting the following Exception.
0x80004005 - Couldn't use ''; file already in use
After some research we detect that almost all the connections still work well but when we try to connect to de MDB file in Share Exclusive mode. Of course, the file is not in use and we have all the grants because we are testing on local Desktop.
The MDB files has a password that sometimes is changed. Thus, we need to set at the Connection String with the following configuration: 'Mode=Share Exclusive;'
If the software tries to open de file without Share Exclusive mode, goes well.
We have found a Workaround. If we reinstall de Data Base Engine the problem goes out but as soon as Office is updated the problem comes again.
We have to reinstall the Database Engine again for Fixing and it has to be done each week if you have the automatic Office update active.
I'm sure this is an Access Driver Error because we have no changed this code for years and we are experimenting these same problem on tens of independetns enviroments.
Does anyone know, how to permanent fix it without disabling Office Updates?
Has anyone any idea if this is going to be fixed?
Tips for reproduce the error:

.NET Framework 4.0 x86 / x64 target compile
Office 2016 or Office 365 x86 / x64
C# Code:

string strConnection = String.Format("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=\"{0}\"; Jet OLEDB:Database Password={1}; Mode=Share Exclusive", new object[] { file, oldPass });
string sql = null;
oldPass = string.IsNullOrEmpty(oldPass) ? "NULL" : oldPass;
newPass = string.IsNullOrEmpty(newPass) ? "NULL" : newPass;
sql = String.Format("ALTER DATABASE PASSWORD {0} {1}", new object[] { newPass, oldPass });
OleDbConnection conexion = null;
OleDbCommand cmd = null;
try
{
conexion = new OleDbConnection(strConnection);
conexion.Open(); //Produces the Exception: 0x80004005 - Couldn't use ''; file already in use
cmd = new OleDbCommand(sql, conexion);
cmd.ExecuteNonQuery();
ok = true;
}
catch (Exception ex)
{
ok = false;
}
finally
{
if (conexion != null && conexion.State == ConnectionState.Open)
conexion.Close(); //Respetar, revisado
}

return ok;



Other tips:

We have the same software compiled for 32 and 64 bits.
If the Office is 32 bits, it breaks the 32-bit Data Base Engine not the 64 one, and the opposite happens if we update Office 64 bits, it breaks the 64-bit Data Base but not the 32 one.

Any clue on this is welcome
Many thanx in advance

Continue reading...
 
Back
Top