- Open the ExoADO1 application
- Add a new combo box to the form as follows:
|
Control |
Name |
Text |
Additional Properties |
Label |
|
Gender: |
|
ComboBox |
cboGender |
|
DropDownStyle: DropDownList |
|
- To update the data source, right-click sqlDataAdapter1 and click
Configure Data Adapter...
- Click Next
- In the Data Adapter Configuration Wizard, in the combo box,
select Server.People.dbo and click Next
- Accept the default Use SQL Statements radio button and click Next
- Change the statement to
SELECT PersonID, FirstName, LastName, GenderID FROM Persons
|
- Click Next and click Finish
- To create a data source for the combo box, from the Data section of
the Toolbox, click SqlDataAdapter and click the form
- Click Next
- In the combo box, select Server.People.dbo and click Next
- Accept the default Use SQL Statements radio button and click Next
- Click Query Builder...
- From the Tables property page of the Add Table dialog box, click
Genders. Click Add and click Close
- In the upper section of the Query Builder window, click the GenderID and
the Gender check boxes
- Click OK
- Click Next and click Finish
- To create a data set for the genders, right-click sqlDataAdapter2
and click Generate Dataset...
- Accept the Existing radio button and accept the Genders check box
- Click OK
- On the form, click the combo box
- In the Properties window, set the properties as follows:
DataSource: dsPersons1.Genders
DisplayMember: Gender
ValueMember: GenderID
DataBindings -> SelectedValue: dsPersons1 - Persons.GenderID
- Double-click an empty area of the form and change the Load event as
follows:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.SqlDataAdapter1.Fill(Me.DsPersons1, "Persons")
Me.SqlDataAdapter2.Fill(Me.DsPersons1, "Genders")
End Sub
|
- Press Ctrl + F5 to test the application
|