Reputation: 19
Here is a code :
Private Sub ComboBoxQC1L1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxQC1L1.SelectedIndexChanged
Dim conn As New SqlConnection
If conn.State = ConnectionState.Closed Then
conn.ConnectionString = ("Data Source=.\SQLEXPRESS;Initial Catalog=OST;Integrated Security=True")
End If
Try
conn.Open()
Dim sqlquery As String = "SELECT * FROM liste_unités where nom_unité = " & ComboBoxC1L1.Text & ""
Dim data As SqlDataReader
Dim adapter As New SqlDataAdapter
Dim command As SqlCommand = New SqlCommand(sqlquery, conn)
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader()
While data.Read
If ComboBoxQC1L1.Text = "ordinaire" Then
LabelPointsC1L1.Text = XXX
ElseIf ComboBoxQC1L1.Text = "élite" Then
LabelPointsC1L1.Text = XXX
ElseIf ComboBoxQC1L1.Text = "médiocre" Then
LabelPointsC1L1.Text = XXX
End If
End While
Catch ex As Exception
End Try
End Sub
Here is the SQL table overview
Into the ComboBoxC1L1, all the "nom_unité" are populated and the LabelC1L1 is changing with the corresponding "cout_unité"
Ex : When ComboBoxC1L1.text = "Arbalétrier", LabelC1L1.text = "7". If the ComboBoxC1L1.SelectedIndex is changing, the LabelC1L1.text is changing to.
Now introducing the ComboBoxQC1L1 with 3 possible values : "ordinaire", "médiocre" and "élite".
I want the LabelPointsC1L1.text to adapt to the correct values (see table overview) while the ComboBoxQC1L1 is changing.
Ex : When ComboBoxC1L1.text = "Arbalétrier", LabelC1L1.text = "7". If ComboBoxQC1L1.text is changing from "ordinaire" to "élite", LabelC1L1.text should become "9". If ComboBoxQC1L1.text is changing from "ordinaire" to "médiocre", LabelC1L1.text should become "5". At last, if ComboBoxQC1L1.text is changing to "ordinaire", LabelC1L1.text should become "7" like initially.
I'm trying to figure by what code should I replace the "XXX" in the code to do this ?
Many thanks :-)
Upvotes: 0
Views: 660