Hi, I am creating a form application that should display information from one dataset into individual textboxes (ie. system name, system id, location name, location id). The textboxes populate upon the selection of a pair of cascading combo boxes. So, the user first selects a system name from the first combobox, then that selection will populate the second combo box for the locations of that system. (This means that each system may have more than one location.) Once the location is selected, each of the 4 textbox should populate with the corresponding data but I'm not quite sure how to write the code..
' Fill out Textboxes
Dim con As MySqlConnection = New MySqlConnection("Server=fafsv-mysql;user id=root;Password=0263;Database=gsais")
Dim cmd As MySqlCommand = New MySqlCommand("SELECT * FROM blsys_systems WHERE SystemName='" & LocationComboBox.Text.ToString & "'", con)
con.Open()
Dim myDA As MySqlDataAdapter = New MySqlDataAdapter(cmd)
Dim ds As DataSet = New DataSet()
Dim hold As Object
hold = myDA.Fill(ds, "blsys_systems")
SystemNameTextBox.Text = hold.SystemName
LocationNameTextBox.Text = hold.LocationName
LocationIDTextBox.Text = hold.LocationID
SystemIDTextBox.Text = hold.SystemID
I know that this is not right but I don't know what to do. Besides populating the textboxes, I also need a datagrid to populate. The data from the datagrid comes from a different dataset but is retrieved using the system ID. This code isn't working as well...
' Fill out first table
Dim cmd2 As MySqlCommand = New MySqlCommand("SELECT SystemID FROM blsys_systems WHERE SystemName='" & LocationComboBox.Text.ToString & "'" & " AND '" & SystemComboBox.Text.ToString & "'", con)
Dim myDB As MySqlDataAdapter = New MySqlDataAdapter(cmd2)
Dim db As DataSet = New DataSet
Dim dt As New DataTable
Dim SystemID As String
SystemID = myDB.Fill(db, "blsys_systems")
Dim itcomponents As MySqlCommand = New MySqlCommand("SELECT * FROM blsys_itcomponents WHERE SystemID='" & SystemID & "'", con)
Dim myIT As MySqlDataAdapter = New MySqlDataAdapter(itcomponents)
Dim IT As Object = myIT.Fill(db, "blsys_itcomponents")
Blsys_itcomponentsBindingSource = IT
Blsys_itcomponentsDataGridView = Blsys_itcomponentsBindingSource.DataSource
I also tried to change lines 11-13 of the last code to:
myIT.Fill(db, "blsys_itcomponents")
Blsys_itcomponentsDataGridView.DataSource = db
Blsys_itcomponentsDataGridView.DataMember = "blsys_itcomponents"
None of it works... Please help!!!!!