Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# cannot find namespace OleDbConnection even though using System.Data.OleDb is there

I have one project (a web application), in production, where I have the following, which works, and then opened up another Visual Studio project (console application) and copy pasted the same code. The problem with the new project (console application) is that while the computer recognizes my namespace "System.Data.OleDb", VS is graying this out, and hovering over OleDbConnection gets the error message

The type or namespace name "OleDbConnection not found (are you missing a using directive or an assembly reference?)

Since my using directive is there, I'm guessing it's the assembly reference, but when I go to Project --> add reference the only options are Projects, Shared Projects, and Browse, and for each of these three tabs there are 0 options to choose from. How can I add this reference?

My simple code is below

using System.Data;
using System.Data.OleDb;
public class DataLayer
{
    public DataLayer()
    {
    }
    static OleDbConnection conn;
    // some other code below
}
like image 845
kashmoney Avatar asked Apr 19 '26 02:04

kashmoney


1 Answers

In Visual Studio

  • Navigate to the Tools Tab
  • Click NuGet Packet Manager
    • Click Nuget Packet Manager Console // A command-line console should pop up at the bottom of Visual Studio
    • Insert the following command
    • Install-Package System.Data.OleDb

It should be good after that

like image 150
user15188170 Avatar answered Apr 21 '26 17:04

user15188170



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!