I have been trying to create a simple login page using Windows Form(vb.net) I connected my MS Access database to my windows form and when I try to write the code, it shows error. Basically the problem is that, When I try to write:
Dim co as New OleDbConnection()
it says that OleDb
is not defined. I tried this in my College computer and it worked perfectly. In the suggestions also it doesn't show OleDbConnection
. Yes, I have used Imports.System.OleDb
and yet it doesn't work. Any solutions? Thanks!
Here is the Code,
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim con As New OleDbConnection()
End Sub
End Class
while writing OleDbConnection
it doesn't appear in the suggestion as well.
Also, I tried this with SqlClient
and had the same problem.
In .NET Framework, the SqlClient
and OleDb
providers are included in the System.Data.dll assembly, which is referenced by default in a WinForms project. In .NET Core, each provider is in its own assembly and you need to add them as required by installing the appropriate NuGet package.
There are a number of ways to use NuGet but I tend to use the GUI built into VS. You can right-click a project in the Solution Explorer and select Manage NuGet Packages to open it. You can then search for the appropriate NuGet package - System.Data.OleDb in this case - and install the latest version or a specific version if desired. That will add the appropriate assembly reference to your project, thus giving you access to types declared in that assembly.