10-13-2012, 01:44 PM
Thanks for the bump, I completely forgot about this post.
Anyway, So, since the combobox contains a list of all of the credit card number that belong to a certain user, we are going to want to do something when the combobox's selected index is changed.
First, we are going to get the credit card's number and save it.
Then, we need to select all of the records from the cc_master table and fill in all of the controls. This is pretty simple to do, we just need to use a new MySQL Query and fill in the data
[code2=vbnet]Private Sub ComboBoxCard_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBoxCard.SelectedIndexChanged
Dim creditCardNumber As String = ComboBoxCard.SelectedItem.ToString
'Here we use a new MySQL call to fill in fields using the existing dbConn
'variable
Dim dbQuery As String = ""
Dim dbCmd As New MySqlCommand
Dim dbAdapter As New MySqlDataAdapter
Dim data As MySqlDataReader
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 * FROM cc_master WHERE ccNumber='" & creditCardNumber & "'"
With dbCmd
.CommandText = dbQuery
.Connection = dbConn
End With
With dbAdapter
.SelectCommand = dbCmd
End With
data = dbCmd.ExecuteReader()
While data.Read()
'Now we can deal with each individual data entry and you can put it into
'various controls
txtExpireMonth.Text = data(2).ToString
txtExpireYear.Text = data(3).ToString
txtCode.Text = data(4).ToString
txtZipCode.Text = data(5).ToString
txtType.Text = data(6).ToString
txtAuthorizedUseStart.Text = data(7).ToString
txtAuthorizedUseEnd.Text = data(8).ToString
End While
'Now we close are vars to save memory
data.Close()
End Sub[/code2]
If you have any questions or this doesn't work, feel free to ask.
Anyway, So, since the combobox contains a list of all of the credit card number that belong to a certain user, we are going to want to do something when the combobox's selected index is changed.
First, we are going to get the credit card's number and save it.
Then, we need to select all of the records from the cc_master table and fill in all of the controls. This is pretty simple to do, we just need to use a new MySQL Query and fill in the data
[code2=vbnet]Private Sub ComboBoxCard_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBoxCard.SelectedIndexChanged
Dim creditCardNumber As String = ComboBoxCard.SelectedItem.ToString
'Here we use a new MySQL call to fill in fields using the existing dbConn
'variable
Dim dbQuery As String = ""
Dim dbCmd As New MySqlCommand
Dim dbAdapter As New MySqlDataAdapter
Dim data As MySqlDataReader
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 * FROM cc_master WHERE ccNumber='" & creditCardNumber & "'"
With dbCmd
.CommandText = dbQuery
.Connection = dbConn
End With
With dbAdapter
.SelectCommand = dbCmd
End With
data = dbCmd.ExecuteReader()
While data.Read()
'Now we can deal with each individual data entry and you can put it into
'various controls
txtExpireMonth.Text = data(2).ToString
txtExpireYear.Text = data(3).ToString
txtCode.Text = data(4).ToString
txtZipCode.Text = data(5).ToString
txtType.Text = data(6).ToString
txtAuthorizedUseStart.Text = data(7).ToString
txtAuthorizedUseEnd.Text = data(8).ToString
End While
'Now we close are vars to save memory
data.Close()
End Sub[/code2]
If you have any questions or this doesn't work, feel free to ask.