Hockey-Splitscreen, Your All-In-One Football Game Room
3D Pro 2 HD Apex DX 6
4. Bind ComboBox with a DataAdapter
In this tutorial, you will learn how to bind a ComboBox control with a DataAdapter. The control will display data from a DataTable and allow for the user to select an item from the ComboBox.
To bind an existing DataTable to a control, use the BindingManager method BindDataTableTo.
1. To begin this tutorial, you must have Visual Studio 2017 installed and the necessary tools for working with data-bound controls. Connect to your SQL Database..
2. Then, open the solution in Visual Studio. Choose File > New Project to open the New Project dialog box. Select Templates > Visual C# > Class Library. Select Console Application as the project type and name it ADuDatabinding.
Add a DataSet to the project as follows:
Choose Database > Manage Databases and add a new database to the App_Data directory.
Add a DataTable to the project as follows:
Choose Data > New DataTable. Select a Table from the Data Source box and enter a name in the TableName box, such as Customers. Then, click Add.
Connect to the data source by choosing Tools > Options. Then, navigate to the Database tab, click the Edit Connection button, and enter the connection string. Choose the database and enter the appropriate server name, the database name, and the user name with the appropriate password.
Select the Customers table, click OK, and choose the Dataset Properties window so that you can add a BindingSource. Choose the BindingSource control from the toolbar.
Add the BindingSource to the form by clicking the field label (select the label, click the Properties button, and enter the DataSource property).
Open the Form1.Designer.cs file and add the following code: