0

Probably the worst part about using Microsoft Access and SQL is trying to connect through the OLEDB connection. The code is on the one drive and has been working without issue but this morning it has came up with this error;

"System.InvalidOperationException: 'The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.'"

Previously I was able to change the CPU from any to x86 which sometimes seemed to fix the problem but now it is not. I am running System.Data.OleDb 7.0.0 which I have not changed since starting this protect.

using System.Data.OleDb;
using System.Data;
using System;

namespace LOGIN_TAKE_FIVE
{
    public partial class Form1 : Form
    {
        OleDbConnection connection = new OleDbConnection();

        public Form1()
        {
            InitializeComponent();
            connection.ConnectionString = (@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:/Users/kiera/LOGIN TAKE FIVE/bin/Debug/net6.0-windows/dbNumber2.accdb");
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            connection.Open();
            OleDbCommand cmd = new OleDbCommand();
            string encryptUser = EncryptString(tbUsername.Text);
            string encryptPassword = EncryptString(tbPassword.Text);
            string regSQL = "INSERT INTO Users ([Username], [Password]) VALUES ('" + encryptUser + "', '" + encryptPassword + "')";
            cmd = new OleDbCommand(regSQL, connection);
            cmd.ExecuteNonQuery();
            connection.Close();
        }

this code was working in full no less than 5 days ago so I am unsure what the problem is. Any help would be greatly appreciated.

FortyTwo
  • 2,414
  • 3
  • 22
  • 33
Kieran
  • 21
  • 3
  • 2
    Does this answer your question? ['Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine](https://stackoverflow.com/questions/6649363/microsoft-ace-oledb-12-0-provider-is-not-registered-on-the-local-machine) – javdromero Feb 13 '23 at 16:01
  • The error is saying that the Access driver isn't installed. Did you update any Office components? – Panagiotis Kanavos Feb 13 '23 at 16:05
  • ACE comes with Microsoft Office. If you do not have Office installed you need to manual add ACE to your machine. – jdweng Feb 13 '23 at 17:03

0 Answers0