Hello Friends , In This Article I Will tell you how you can Retrieve Data Base Column Value In Combo Box Of C# Windows Desktop Application. So Let's Start .
Bind Combo Box With Data Base In C# Windows Desktop Application
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Step : 1 Open Your Visual Studio And Create New Project From File Menu > New > Project
Step : 2 Select Windows Desktop App From Menu
Step : 3 Enter Your Project Name And Path Of Your Location Where You Want To Save Your Project
Step : 4 Create Design As You Want . As You See In Below Image Here I Only Add Label And A Combo Box Which Is Empty.
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Step : 5 Now Add Data Base File From Right Click On Your Project Name From Solution Explorer Add > New File Or You Can Simply Use Short Cut Key Ctrl+Shift+A
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Step : 6 Select Service Based Database , Give Name As You Want And Click On Add
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Step :7 Now Create New Table , To Create Table Double Click On Your Database File It Will Open Server Explorer Then Right Click On Table > Add New Table . As You See In Below Image Our Table Has Only Two Column Id And Name .
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Here Is The Data Of Our Table
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Step : 8 Now Copy Your Connection String By Right Click On Database Name > Modify Connection > Advance .
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Step : 9 Now Add New SQL Connection On Your Form Load Event As Show In Below Image .
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Step : 10 Here i Create A Separate Function For Get Data From Database And Bind in Combo Box And That Function I Called In Form Load Event . You Can Also Write That Code Directly On Form Load Event.
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Step : 11 Now Run Your Application As You See That Combo Box Get All The Name From Database.
 |
Bind Combo Box With Data Base In C# Windows Desktop Application |
Below Is The Full Source Code of This Project
I Hope You Find this Article helpful . if You Learn Anything From This Article Kindly Share With Your Friends. Thank You.
0 Comments