Note that there are some explanatory texts on larger screens.

plurals
  1. POComboBox Isn't Being Populated with MySQL Query Result - How do I resolve it?
    text
    copied!<p>I trust you're all well. I would like to know what I'm doing wrong and how to fix it. My intent with the code below is the query my MySQL database and display one column of the table inside a ComboBox. Then, when that value in the ComboBox is selected, I want all the records associated to be populated into other controls on my form (I'll create a separate question for this part).</p> <p>Right now, the query is working but the ComboBox isn't being populated. What am I doing wrong? Please help, thanks.</p> <p>HERE'S MY CODE:</p> <pre><code> Private Sub RetrieveMySQLdata() Try Dim dbConn As New MySqlConnection Dim dbQuery As String = "" Dim dbCmd As New MySqlCommand Dim dbAdapter As New MySqlDataAdapter Dim dbTable As New DataTable If dbConn.State = ConnectionState.Closed Then dbConn.ConnectionString = String.Format("Server={0};Port={1};Uid={2};Password={3};Database=accounting", FormLogin.ComboBoxServerIP.SelectedItem, My.Settings.DB_Port, My.Settings.DB_UserID, My.Settings.DB_Password) dbConn.Open() End If dbQuery = "SELECT *" &amp; _ "FROM cc_master INNER JOIN customer ON customer.accountNumber = cc_master.customer_accountNumber " &amp; _ "WHERE customer.accountNumber = '" &amp; TextBoxAccount.Text &amp; "'" With dbCmd .CommandText = dbQuery .Connection = dbConn End With With dbAdapter .SelectCommand = dbCmd .Fill(dbtable) End With Dim i As Integer For i = 0 To dbTable.Rows.Count - 1 ComboBoxCard.ValueMember = "ccNumber" Next Catch ex As Exception MessageBox.Show("A DATABASE ERROR HAS OCCURED" &amp; vbCrLf &amp; vbCrLf &amp; ex.Message &amp; vbCrLf &amp; _ vbCrLf + "Please report this to the IT/Systems Helpdesk at Ext 131.") End Try End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload