I am looking to get the text value of the ticked checkboxes and use that text value as a parameter for my SQL statement. so far the code I wrote gets the first checked value but not the rest after that. does anyone have any ideas the best way to do this ? also note I have an indefinite amount of checkboxes that will constantly change so looking for something that doesn't require me to write code for each option.
Below is a sample of the code I have so far which as said above only gets the first checked box.
For Each item As ListItem In chkBox.Items
If item.Selected = True Then
Using con As New SqlConnection(GblSqlCon)
Using cmd As New SqlCommand("SELECT DISTINCT ID, NAME, ADDRESS, COUNTRY, DOB FROM [db].[dbo].[tbl_TEST] WHERE COUNTRY = @COUNTRY AND DOB = @DOB")
cmd.Parameters.AddWithValue("@DOB", txtDOB.Text)
cmd.Parameters.AddWithValue("@COUNTRY", chkBox.Text)
MsgBox(chkBox.Text)
Using sda As New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using dt As New DataTable()
sda.Fill(dt)
End Using
End Using
End Using
End If
Next