0

this is my code developed with c # and it does not connect me to the database dont know why, i am using everything correctly, the error is The provider 'Microsoft.Jet.OLEDB.4.0' is not registered on the local computer.

    static public void conectar()
    {
        try {

            string gsPatchUbicar = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            gsPatchUbicar = gsPatchUbicar.Substring(6);
            DireccionBD = gsPatchUbicar + "\\db_deportes.mdb";
            string stringconeccion = string.Format(@"PROVIDER=Microsoft.Jet.OLEBD.4.0;Data Source={0}; Jet OLEBD:Database Password={1}", DireccionBD, PasswordBD);
            getConexion = new OleDbConnection(stringconeccion);
            getConexion.Open();
            MessageBox.Show("Conexion a base de datos exitosa!!", "ok", MessageBoxButtons.OK, MessageBoxIcon.Information);
        } catch (Exception H)
        {
            MessageBox.Show("hay un error en la conxion de base de datos");
        }

    }
  • Hi! Have a read through this link: https://social.msdn.microsoft.com/Forums/en-US/b5a79958-5bce-4229-a69f-75589b6240a8/faq-item-solution-fails-on-64-bit-system-with-error-8220microsoftjetoledb40-provider-is-not?forum=adodotnetdataproviders – LordPupazz May 26 '20 at 13:54
  • The JET should be in the c:\Windows\System32 folder (msjet40.dll). On my Windows 10 machine it is in the SysWoW64 folder. – jdweng May 26 '20 at 13:56
  • A few notes about it [here](https://stackoverflow.com/a/54352568/7444103).Possibly, use the `Microsoft.ACE.OLEDB.12.0` or `Microsoft.ACE.OLEDB.16.0` providers. Compile using the `AnyCPU` profile. -- This: `gsPatchUbicar = gsPatchUbicar.Substring(6); DireccionBD = gsPatchUbicar + "\\db_deportes.mdb";` is not the way to locate the database. Use the `|DataDirectory|` feature. Some info [here](https://stackoverflow.com/q/1409358/7444103) and [here](https://stackoverflow.com/q/12187068/7444103). – Jimi May 26 '20 at 14:09

0 Answers0