The code to read the content from an Excel file does not work in my new program, see attached image. It works without problems in another older program I made a while ago with .NET Framework 4.0. The new program is with .NET 8.0.
Any suggestions on what I need to do to get it working?
Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim dataSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [" + selectedNOD + "$A1:I49]", MyConnection)
Visual Studio 2022 Windows Forms APP (Visual Basic)
The issue is most likely that you haven't installed the System.Data.OleDb
NuGet package. In .NET Framework projects, the System.Data.dll assembly is generally referenced by default and that contains the SqlClient
, OleDb
and Odbc
ADO.NET providers. In .NET Core projects, you have to install the NuGet package(s) for the specific provider(s) you want. This will be the case for many types in .NET Core. Note that .NET 5 and later are based on .NET Core.
There are various ways that you can install NuGet packages but the simplest is probably to right-click the project, select the option to manage NuGet packages and then use the GUI provided.