Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I populate my form using Listview
    primarykey
    data
    text
    <p>I've successfully taught myself how to pull some data from a MySQL database and bind it to a ListView control (ListViewCard).</p> <p>Now I can't figure out how to use the SelectedIndexChanged event to inerate through the records and populate some other controls on my form (i.e, 7 textboxes, 2 comboboxes, and 2 datetimepickers).</p> <p>Your help would be greatly appreciated. Here's my code:</p> <pre><code>Private Sub loadCard() Try 'FOR MySQL DATABASE USE 'Dim dbQuery As String = "" 'Dim dbCmd As New MySqlCommand 'Dim dbAdapter As New MySqlDataAdapter Dim dbTable As New DataTable Dim i As Integer 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 ListViewCard.Items.Clear() For i = 0 To dbTable.Rows.Count - 1 With ListViewCard .Items.Add(dbTable.Rows(i)("ccID")) With .Items(.Items.Count - 1).SubItems .Add(dbTable.Rows(i)("ccNumber")) .Add(dbTable.Rows(i)("ccExpireMonth")) .Add(dbTable.Rows(i)("ccExpireYear")) End With End With Next Catch ex As MySqlException 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 dbConn.Close() End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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