I have skillID field which is a checkbox where values are from tblSkills. If the user checks two checkbox in skillID field, two records will be insert in tblConstituentSkills.
I also tried this code:
For Each id As Object In skillID.ToString.Split(",")
Using sql As New SqlProcedure("spInsertSkill")
sql.AddParameter("@ConstituentIdNo", constituentIdNo)
sql.AddParameter("@skillID", skillID)
sql.ExecuteNonQuery()
End Using
Next
but it only inserts one record and the value inserted in skillID field is "id1,id2".
I badly needed to solve it as soon as possible. Thanks for your help.
What I have tried:
I have tried this code:
Dim varSkillID() As String = Split(skillID, ",")
Dim sql As String = String.Empty
For i As Integer = 0 To varSkillID.Length - 1
If varSkillID(i) <> "" Then
sql = "INSERT INTO tblConstituentSkills (ConstituentIdNo, skillID) VALUES (" & constituentIdNo & ", " & varSkillID(i) & ")"
End If
Next i
but it does not inserts anything.