Show Database Values in DataGridView in C#

If you want to show the database values in C#, Here you’ll find a really simple way to retrieve database values and show them in a data grid view in visual c#.

Step 1:

First of all, create a new window forms application project and add a new datagridview on your form.

Add Data Grid view in C#.

Step 2:

Add and configure SLRDbConnector in your project. Please follow this link to learn how to configure SLRDbConnector.

Step 3:

After successful configuration of the SLR Db Connector, You are ready to go a step further. Now it’s time to retrieve data from the database. For this, go to the onLoad event of the Form and add the Following Code.

DbConnector db = new DbConnector();
db.fillDataGridView(“select * from tblUsers”,datagridview1);
//datagridview1 is the name of the data grid view and tblUsers is the name of Users Table.

Step 4:

Now Run your application and SLR Db Connector will do its work for you and the list of Users will be displayed on the data grid view.

I hope it will work for you.

Video Demo:

for the video Demo, Please follow the video below: Database Values in DataGridView

Database Values in DataGridView

For more video examples, Please subscribe to out YouTube Channel C# Ui Academy.

Leave a Reply

Your email address will not be published. Required fields are marked *