Jorram
Jorram
CC#
Created by Jorram on 12/4/2024 in #help
Issues when attempting to use.Net 8 to connect to an Access database
Hello folks, Do some of you know how to connect a .NET 8 application with an Access database .accdb? I use this code, but I'm receiving this error: "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.." PS-1: Yes, I'm in a Windows environment. PS-2: Sorry I don't know where to post this.
public void Connection()
{
const string connectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "C:\\Users\\MICRO-52\\Desktop\\EoExperience\\PreRegistro.mdb;";


const string insertSQL =
"SELECT * FROM PreRegistro;";

using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbCommand command = new OleDbCommand(insertSQL);

command.Connection = connection;

try
{
connection.Open();
command.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
public void Connection()
{
const string connectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "C:\\Users\\MICRO-52\\Desktop\\EoExperience\\PreRegistro.mdb;";


const string insertSQL =
"SELECT * FROM PreRegistro;";

using (OleDbConnection connection = new OleDbConnection(connectionString))
{
OleDbCommand command = new OleDbCommand(insertSQL);

command.Connection = connection;

try
{
connection.Open();
command.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
13 replies