Ok here is the required feature:
To send data gathered from a database inside a UserControl to the main form which houses the UserControl.
Hierarchy at present:
Mainform
--FlowLayoutPanel
----UserControl
The UserControls are generated on the fly by a client list in a database. This all works fine.
When you click on the UserControl, the UserControl gathers the information associated with the client and stores them in to strings.
What should happen is the strings are then passed and set on screen to the main form, but this doesn't happen.
There is no real point in me posting code from the main window as the code there is working and does exactly what it should be, however below is the code that shows what should happen when the UserControl is clicked on.
Public Function get_ind_data(indclid As String)
Dim firstname, lastname, middlename, postcode, address1, address2, county, country, email, compname, phone, clientid, pass As String
Try
Dim ind_fetcher As New MySqlConnection("REMOVED")
Using ind_command As New MySqlCommand("SELECT * FROM clients WHERE clid='" + indclid + "'", ind_fetcher)
ind_fetcher.Open()
Using ind_reader As MySqlDataReader = ind_command.ExecuteReader()
While ind_reader.Read()
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_firstname")) Is DBNull.Value) Then
firstname = ind_reader.GetString(ind_reader.GetOrdinal("cl_firstname"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_lastname")) Is DBNull.Value) Then
lastname = ind_reader.GetString(ind_reader.GetOrdinal("cl_lastname"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_middlenames")) Is DBNull.Value) Then
middlename = ind_reader.GetString(ind_reader.GetOrdinal("cl_middlenames"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_postcode")) Is DBNull.Value) Then
postcode = ind_reader.GetString(ind_reader.GetOrdinal("cl_postcode"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_address_1")) Is DBNull.Value) Then
address1 = ind_reader.GetString(ind_reader.GetOrdinal("cl_address_1"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_address_2")) Is DBNull.Value) Then
address2 = ind_reader.GetString(ind_reader.GetOrdinal("cl_address_2"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_county")) Is DBNull.Value) Then
county = ind_reader.GetString(ind_reader.GetOrdinal("cl_county"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_country")) Is DBNull.Value) Then
country = ind_reader.GetString(ind_reader.GetOrdinal("cl_country"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_email")) Is DBNull.Value) Then
email = ind_reader.GetString(ind_reader.GetOrdinal("cl_email"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_compname")) Is DBNull.Value) Then
compname = ind_reader.GetString(ind_reader.GetOrdinal("cl_compname"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("cl_telephone")) Is DBNull.Value) Then
phone = ind_reader.GetString(ind_reader.GetOrdinal("cl_telephone"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("clientid")) Is DBNull.Value) Then
clientid = ind_reader.GetString(ind_reader.GetOrdinal("clientid"))
End If
If (Not ind_reader.GetString(ind_reader.GetOrdinal("clpass")) Is DBNull.Value) Then
pass = ind_reader.GetString(ind_reader.GetOrdinal("clpass"))
End If
End While
ims_submodule_directory.lbl_title_clname.Text = firstname + " " + lastname
MessageBox.Show(firstname + " " + lastname, "DEBUG globalclasses.vb On line 120")
End Using
ind_fetcher.Close()
End Using
Catch ex As MySqlException
End Try
End Function
I would very much be thankful for any advice, I have been racking my brains out for the past two weeks now.
Thanks a bunch
Jack