the code display 2 colunms in one combo box from a table. i have table with 2 columns account_type and account_name. the account_type is an abbreviation(codes) which would be stored in a new table when selected. I want the code when the combo is click, would display the code-account_type and account_name in the same combo box.
Private Sub cboAccount_type_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboAccount_type.SelectedIndexChanged
Dim cn As New SqlConnection(ConnectionString)
Dim query As String = "Select Concat(Account_type, ' - ', Account_Name) As AccountDesc, Account_type from Accounts"
Try
cn.Open()
Dim Account_type, Account_Name As String
Dim Table As New DataTable()
put = "Select * from Accounts"
cboAccount_type.DisplayMember = "AccountDesc"
cboAccount_type.ValueMember = "Account_type"
'String[]{"Account_Type","AccountDesc"}
cboAccount_type.DataSource = theDataTable
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub