简体   繁体   English

c# 连接打开后,程序使用 Microsoft.Jet.OLEDB.4.0 出错 需要 MDAC 2,6 或更高版本

[英]c# Program gets an error using Microsoft.Jet.OLEDB.4.0 after connection open MDAC 2,6 or later is required

An old C# program no longer works to read an MS-Access database through Jet.OLE.DB.旧的 C# 程序不再适用于通过 Jet.OLE.DB 读取 MS-Access 数据库。 Also a new compilation without any changes of the source code didn't help.此外,没有对源代码进行任何更改的新编译也无济于事。

My laptop is running Windows 10 and the MS Office is LTSC Professional Plus 2021 32-bit.我的笔记本电脑运行的是 Windows 10,MS Office 是 LTSC Professional Plus 2021 32 位。

I uninstalled Office LTSC 64-bit to install Office LTSC 32-bit and am trying to fix the problem installing the following recommended runtime packages:我卸载了 Office LTSC 64 位以安装 Office LTSC 32 位并尝试解决安装以下推荐运行时包的问题:

  1. AccessDatabaseEngine.exe AccessDatabaseEngine.exe
  2. mdac28sdk.msi mdac28sdk.msi
  3. AccessRuntime2007.exe AccessRuntime2007.exe
  4. AccessRuntime_x86_en-us.exe AccessRuntime_x86_en-us.exe

Our customer uses MS Access because he has linked thousands of macros in Excel with Access and switching to other databases is not possible.我们的客户使用 MS Access,因为他已将 Excel 中的数千个宏与 Access 链接起来,并且无法切换到其他数据库。

It wasn't possible to use OLE in the current Windows 10 OS 64bit environment and that's why I switched to ODBC and it works.在当前的 Windows 10 OS 64 位环境中无法使用 OLE,这就是我切换到 ODBC 并且它可以工作的原因。

I gave up using Visual Studio 2022 and switched to ACE for now because VS 2022 is really weird.我放弃了使用 Visual Studio 2022,暂时改用 ACE,因为 VS 2022 真的很奇怪。 I tried updating the current VS 2017 project but I couldn't select a.NET Frame higher than 4.8.我尝试更新当前的 VS 2017 项目,但我不能 select a.NET Frame 高于 4.8。 I created a new project and then I could select.NET 6 or 7 if I would select "Windows Forms App" instead of "Windows Forms App .NET Framework)" but the toolbox is empty.我创建了一个新项目,然后我可以选择 .NET 6 或 7,如果我愿意 select“Windows Forms App”而不是“Windows Forms App .NET Framework)”但工具箱是空的。

  /*old code*/
  string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Datenbank + ";";
  OleDbConnection  conn = new OleDbConnection(connStr);
  String strCommand = "SELECT * FROM Tickets WHERE [Ticket_Nummer] = @Ticket_Nummer";
  OleDbDataAdapter da = new OleDbDataAdapter(strCommand, conn);
  da.SelectCommand.Parameters.Add("@Ticket_Nummer", OleDbType.Integer).Value = Ticket_Nummer;
  /*new code*/
  string connStr = "Driver={Microsoft Access Driver (*.mdb)};"
      + "Dbq="+ Datenbank+";Uid=Admin;Pwd=;";
  OdbcConnection conn = new OdbcConnection(connStr);
  String strCommand = "SELECT * FROM Tickets WHERE [Ticket_Nummer] = ?";
  OdbcDataAdapter da = new OdbcDataAdapter(strCommand, conn);
  da.SelectCommand.Parameters.Add("@Ticket_Nummer", OdbcType.Numeric).Value = Ticket_Nummer;
  /*rest code*/
  DataSet  DataSet = new DataSet();
  da.Fill(DataSet, "TICKET");
  DataTable dataTable = DataSet.Tables[0];
  DataTableReader  dr = new DataTableReader(dataTable);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Microsoft.Jet.OLEDB.4.0连接导入Excel工作表时出错 - Getting error when using Microsoft.Jet.OLEDB.4.0 connection for import excel sheet 无法使用Microsoft.Jet.OLEDB.4.0创建Excel文件 - Cannot create excel file using Microsoft.Jet.OLEDB.4.0 Microsoft.Jet.Oledb.4.0 提供程序未在本地计算机上注册 c# - Microsoft.Jet.Oledb.4.0 provider is not registered on the local machine c# microsoft.jet.oledb.4.0提供程序未注册 - The microsoft.jet.oledb.4.0 provider is not registered Microsoft.Jet.OLEDB.4.0转换字符 - Microsoft.Jet.OLEDB.4.0 Converting Characters Microsoft.Jet.OLEDB.4.0提供程序未注册 - Microsoft.Jet.OLEDB.4.0 provider is not registered 将连接字符串从Microsoft.Jet.OLEDB.4.0转换为Microsoft.ACE.OLEDB.12.0提供程序 - Converting connection string from Microsoft.Jet.OLEDB.4.0 to Microsoft.ACE.OLEDB.12.0 provider Microsoft.Jet.OLEDB.4.0的提供程序未在本地计算机上注册 - Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine 安装驱动程序后仍显示Microsoft.Jet.OLEDB.4.0'提供程序未在本地计算机上注册 - After installing driver still it shows Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine Microsoft.Jet.OLEDB.4.0读取csv文件的奇怪问题 - Microsoft.Jet.OLEDB.4.0 weird issue reading csv file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM