How to display MS Access table on DataGridView VB.Net

December 18, 2015 | By | Reply More

Continuing my previous tutorial, here I want to show you how to display or populate MS Access table into a DataGridView under Visual Basic .NET. Its pretty easy to load and display MS Access table on our program/form.

Design the form

form 1

As you can see, I have two button Connect and Show Data. The Connect button is used to connect to the database and the other one is to display a table content to DataGridView.

The Code

First we need to create a module. This module will handle every connections to the database through OleDb connection. To add a module, go to Project | Add New Item. Select Module from the list and enter the name of the new module.

add module to vb.net 2015

The following code are typed inside a module called MyModuleConnect

Now back to the main form and we will add code for the Connect button. Connect button will attempt to open the connection to the database.

vb.net tutorial 01

Now, Show Data button code:

Run the program

vb.net tutorial 02

Thank you. Hope this is useful for anyone who wants to start learning Visual Basic 2015.

Tags: , , , , ,

Category: Programming, VisualBasic.NET

Leave a Reply