Reputation: 442
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
}
Upvotes: 9
Views: 14823
Reputation: 171
In Visual Studio
It should be good after that
Upvotes: 17
Reputation: 1811
The project needs a reference to System.Data.dll to be able to resolve. That dll can be located in the following directory (your use may vary based on framework, but pretty standard structure): C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2.
You should have an assmeblies section in your "Add Reference" window, but you can add by browsing to the location as well.
Upvotes: 0
Reputation: 2089
You are missing the reference to System.Data, where this would be contained. Ideally you should ensure it is checked under References, but apparently you tried that.
You could always just edit the project file and add it manually, e.g.
Upvotes: 0