Database Windows Form

C# – Fill Listbox from Sql Server Database

Here in this post, I will show you how to fill / populate data to ListBox control from Sql database records in C# Windows Form Application.

The listbox will populated from database table using sqlDataReader.

Step 1: We will use the Customers table in Northwind database.
Step 2: 
Step3: Write a Namespace for connectivity as in the following code snippet.

Step 4: Define global variables.

Step 5: Create source code for  Button1.

We will list CompanyNames.

Finally, finished  the project.

Here are the all codes:

Output: 

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.