Click here to Skip to main content
16,012,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

VB
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:
VB.NET
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.
Posted
Updated 26-Jul-16 20:21pm
v2

 
Share this answer
 
where do you get the constituentNo ??
but u can use this code somehow.

For Each i In skillID.CheckedItems
Using sql As New SqlProcedure("spInsertSkill")
sql.AddParameter("@ConstituentIdNo", constituentIdNo)
sql.AddParameter("@skillID", itm.Tostring)
sql.ExecuteNonQuery()
End Using
Next
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900