How to wire a ComboBox to a
DataSet
Sub LoadAddressTypes()
Dim objConn As New SqlConnection(cs.ConnString)
Dim objCommand As New SqlCommand()
Dim objDa As New SqlDataAdapter()
Dim objDs As New DataSet()
Dim objCommandBuilder As
New SqlCommandBuilder()
Dim sSQL As String = "Select *
From AddressTypes order by AddressType"
objCommand.CommandText = sSQL
objCommand.Connection = objConn
objDa.SelectCommand = objCommand
objDa.Fill(objDs, "AddressTypes")
objConn.Close()
Dim i As Integer
cmbAddressType.Items.Clear()
'*************************************************
'*************************************************
'Load a blank item into the combobox....
Dim dr As DataRow =
objDs.Tables(0).NewRow
dr("Addresstype") = vbNullString
dr("id_AddressType") = -1
objDs.Tables(0).Rows.InsertAt(dr, 0)
'*************************************************
'*************************************************
cmbAddressType.DisplayMember = "AddressType"
cmbAddressType.ValueMember = "id_AddressType"
cmbAddressType.DataSource = objDs.Tables(0)
End Sub