Binding a combo box to update a list view
Hi i am trying to retrieve information from two database tables so that the information can be used to update a listview. The only problem is that this requires me to bind a combo box and i have no idea how to do this so that it actually works.
Here is my code so far:
Private Sub populateCboClient()
sourceData = New DatabaseConnection
Dim dataSet As New DataSet
Try
' Get all clients in a DataReader object
sourceData.SQL = "qryClientName"
sourceData.InitialiseCommand()
sourceData.OpenConnection()
sourceData.DataReader = sourceData.Command.ExecuteReader
sourceData.FillDataSet(dataSet, "tblClients")
' check data exists
If sourceData.DataReader.HasRows Then
' process all rows
'While sourceData.DataReader.Read()
'cboClient.Items.Add(sourceData.DataReader.Item("C liName"))
cboClient.DataSource = sourceData.DataReader
cboClient.DisplayMember = "qryClientName"
cboClient.ValueMember = "CliAccountNumber"
'cboClient.DataBindings(dataSet)
'End While
End If
sourceData.DataAdapter.Dispose()
Catch ExceptionErr As Exception
MessageBox.Show(ExceptionErr.Message)
Finally
' cleanup
sourceData.Dispose()
sourceData = Nothing
dataSet.Dispose()
dataSet = Nothing
End Try
End Sub
I don't understand how to actually bind the information so that the Client Name is the piece of information showing in the cbo and Client Number is the piece of information being used to perform search to update List View.
Any ideas?
Thanks
Amethyst
|