To play the demo, you need to create a sample Microsoft Access Database, then create a new Windows Forms Application project.
To connect to the access database in Visual Studio, you need to select Server Explorer, then select the connection icon to connect to the database.
Clicking the Change button, then select change your data source to Microsoft Access Database file.
Click OK to continue
Next, you need to select the Microsoft Access Database file you want to connect.
Finally, you need to check the connection, if the connection fails, you need to install the microsoft access engine, then close and reopen your visual studio to reconnect the access database.
Note, To fix Unrecognized database format '*..accdb' for Microsoft Access Database file or Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine you should install the Microsoft Access Engine, try to 32 bit. If you can't install 32 bit you can remove the Microsoft Office, then install Microsoft Access Engine 32 bit and reinstall the Microsoft Office 32 bit or 64 bit that you want.
After connecting to the access database successfully, you will see your database on the left, under server explorer.
You need to create a DataSet, then drag the tables that you want to connect from the access database into your DataSet.
Next, Open your form designer, then drag the DataGridView control from the visual studio toolbox to your winform.
Finally, you need to add a DataSource to your DataGridView. As you can see, Visual Studio automatically creates bindingSource, which helps connect data between the application and the access database.
private void Form1_Load(object sender, EventArgs e)
// TODO: This line of code loads data into the 'appData.Contact' table. You can move, or remove it, as needed.
Now open the app.config file and you'll see the connection string is automatically added to the configuration file
Through this article, I have shown you how to connect the acccess database from visual studio and windows forms application using c # programming language.
In addition, I have shown you how to fix errors connecting to an access database. Such as, 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine or how to fix Microsoft Access Unrecognized Database Format Error.