-1

An old C# program no longer works to read an MS-Access database through Jet.OLE.DB. 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.

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:

  1. AccessDatabaseEngine.exe
  2. mdac28sdk.msi
  3. AccessRuntime2007.exe
  4. 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.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
MarcSS
  • 1
  • 2
  • MDAC 32-bits is part of Windows and includes the JET OLEDB driver, so that can't be the problem if the program is 32 bits. No additional installs are required. With the information provided, we can only guess what the problem is instead of providing a meaningful answer – Erik A Nov 16 '22 at 11:15
  • https://learn.microsoft.com/en-us/office/troubleshoot/access/cannot-use-odbc-or-oledb Click-to-Run installations of Office run in an isolated virtual environment on the local operating system. Some applications outside Office may not be aware of where to look for the installation in the isolated environment. I've followed the "Resolution advice" but it didn't work. – MarcSS Nov 16 '22 at 13:17
  • That's in no way related to this problem – Erik A Nov 16 '22 at 14:27
  • Really, you said mdac comes with win32. Nice, but my laptop is a 64-bit OS Windows 10. As far as I know Office uses outdated 32-bit drivers and if you want to go to 64-bit you should use ACE and not OLE, but this only works with Visual Studio 2022. Perhaps you are experienced enough to suggest another way to read MS Access with more modern drives using C#. If not please don't reply..... – MarcSS Nov 16 '22 at 15:02
  • 1
    No, no, I said MDAC 32-bits comes with Windows. It comes with 64-bits Windows as well as 32-bits Windows. MDAC 64-bits doesn't exist. Are you actually targeting 32-bits Windows? Since if not, your program will indeed not work, and you'd need to swap to ACE, but without code I can't suggest how to change that code. – Erik A Nov 16 '22 at 15:07
  • It looks like this question needs a minimal reproducible example. I suggest figuring out where the error is firing in the C# code and trying to post that part of the code in the format of a minimal reproducible example. – mazoula Nov 18 '22 at 05:50

1 Answers1

0

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.

I gave up using Visual Studio 2022 and switched to ACE for now because VS 2022 is really weird. I tried updating the current VS 2017 project but I couldn't select a NET Frame higher than 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.

  /*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);
MarcSS
  • 1
  • 2