Compress Access Database with C#

Asked

Viewed 165 times

1

I have a method to compress my base Access, but when I run the program I have the following error:

Error:

A catch Exception brings this message: {"Retrieving the COM class Factory for Component with CLSID {DE88C160-FF2C-11D1-BB6F-00C04FAE22DA} failed due to the following error: 80040154 Unregistered class (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))." } System.Exception {System.Runtime.Interopservices.Comexception}

I couldn’t identify it. It follows code:

try
{
    JRO.JetEngine jetEngine = (JRO.JetEngine)Activator                        
                     .CreateInstance(Type.GetTypeFromProgID("JRO.JetEngine"));
    var arquivoTemporario = System.IO.Path.GetTempFileName();
    arquivoTemporario = System.IO.Path.ChangeExtension(arquivoTemporario, "mdb");
    string templateConnectionString = "Data Source={0};Provider=Microsoft.Jet.OLEDB.12.0;";
    string connectionStringFonte = string.Format(templateConnectionString, caminhoMdb);
    string connectionStringTemp=string.Format(templateConnectionString,arquivoTemporario);

    jetEngine.CompactDatabase(connectionStringFonte,connectionStringTemp);
    System.IO.File.Copy(arquivoTemporario, caminhoMdb, true);
    System.IO.File.Delete(arquivoTemporario);
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}
  • A catch Exception brings this message: {"Retrieving the COM class Factory for Component with CLSID {DE88C160-FF2C-11D1-BB6F-00C04FAE22DA} failed due to the following error: 80040154 Unregistered class (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))." } System.Exception {System.Runtime.Interopservices.Comexception}

  • puts this in your question, please help in visualizing the problem. do not forget to put between "" (like I put your JRO error"

1 answer

0


  • Obg Leonado, problem solved!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.