Reputation: 40
When I try to use OLeDBConnection or OleDBDataAdapter, it is not getting reconized by the project
I have Already imported the 'System.Data.OleDB'
What can I do to fix that and use the objects OleDbDataAdapter and OleDbConnection?
Upvotes: 2
Views: 3401
Reputation: 12684
While System.Data.OleDb
is not part of .Net Core, System.Data.OleDb
IS available for .Net Core, as a nuget package. Available here: https://www.nuget.org/packages/System.Data.OleDb/
So, you have to explicitly add the nuget package to your project.
Upvotes: 0
Reputation: 54457
OLE DB only works on Windows, so it is not part of .NET Core, which is cross-platform. .NET 5.0 is .NET Core. .NET Framework will not be developed beyond version 4.8, so 5.0 onwards is the only .NET, hence the dropping of the "Core" suffix.
As is always the case, no matter what type you're using or framework you're targeting, if you want to use a type then you need to reference the assembly that that type is declared in. Importing a namespace is NOT the same thing as referencing an assembly. Read this for more information on that.
In .NET Core projects, you reference an assembly by adding the appropriate NuGet package. If you had read the documentation for the OleDbConnection
class (here is the Australian version) then you'd have seen that it is declared in the System.Data.OleDb.dll assembly. All you need to do is add the System.Data.OleDb NuGet package to your project and you're away.
If you're going to be using .NET 5.0 or any other version of .NET Core then you need to know about NuGet and how to find and add packages. If you don't know that already, stop what you're doing and spend the time to learn.
Upvotes: 2