Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loading DB data into Combobox then populate TextBox Controls
#1
Hey guys,

I'm using the following code to pull data from two tables in my MySQL database. Currently, the data is being loaded directly to the TextBox controls on my form.

What I want to do is this, but don't know how:
  • 1. Load only Credit Card Number (ccNumber) into a ComboBox
  • 2. Load the data into the TextBox controls only after the Credit Card loaded earlier has been selected from the ComboBox

HERE'S MY CURRENT CODE:
[code2=vbnet]Public Sub InitiateQuery()

Try
If TextBoxAccount.Text = "" Then
MessageBox.Show("Sorry, you must enter an ACCOUNT# before proceeding!")
TextBoxAccount.Focus()
Else
dbConn = New MySqlConnection("Server=" & FormLogin.ComboBoxServerIP.SelectedItem & ";Port=3306;Uid=hello;Password=123##123;Database=accounting")
If dbConn.State = ConnectionState.Open Then
dbConn.Close()
End If
dbConn.Open()
Dim dbAdapter As New MySqlDataAdapter("SELECT * FROM customer a INNER JOIN cc_master b ON a.accountNumber = b.customer_accountNumber WHERE a.accountNumber = " & TextBoxAccount.Text, dbConn)
Dim myDatatable As New DataTable
dbAdapter.Fill(myDatatable)
If myDatatable.Rows.Count > 0 Then
'MessageBox.Show("Customer Account Found!")
TextBoxLastName.Text = myDatatable.Rows(0).Item("nameLAST")
TextBoxFirstName.Text = myDatatable.Rows(0).Item("nameFIRST")
TextBoxSalutation.Text = myDatatable.Rows(0).Item("nameSALUTATION")
TextBoxCompanyName.Text = myDatatable.Rows(0).Item("nameCOMPANY")
TextBoxCard.Text = myDatatable.Rows(0).Item("ccNumber")
TextBoxCardType.Text = myDatatable.Rows(0).Item("ccType")
TextBoxExpireMonth.Text = myDatatable.Rows(0).Item("ccExpireMonth")
TextBoxExpireYear.Text = myDatatable.Rows(0).Item("ccExpireYear")
TextBoxCVV2.Text = myDatatable.Rows(0).Item("ccCode")
TextBoxZip.Text = myDatatable.Rows(0).Item("ccZipcode")
Else
MessageBox.Show("No Credit/Debit Card on file for this customer! Please try again!")
TextBoxAccount.Focus()
End If
dbConn.Close()
End If
Catch ex As Exception
MessageBox.Show("A DATABASE ERROR HAS OCCURED" & vbCrLf & vbCrLf & ex.Message & vbCrLf & _
vbCrLf + "Please report this to the IT/Systems Helpdesk at Ext 131.")

End Try

End Sub[/code2]

Thanks to you Brandon, I was able to learn how to do this query following your video tutorials.
//Kismet


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I fill my form with MySQL data based on Combobox? kismetgerald 8 26,861 10-14-2012, 09:05 PM
Last Post: brandonio21
  Extracting Data From A Website Bradley 3 14,774 05-10-2012, 01:03 AM
Last Post: Bradley
  Displaying Data in WebBrowser VicDesigns 10 33,755 08-01-2011, 11:32 AM
Last Post: brandonio21
  Update Data Tabel From Edit mfbf 1 8,587 07-30-2011, 12:54 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)