Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2012

    Unanswered: Please I need help with this

    Please I need help

    I have a list of ClassID that is stored based on users multi select on a listview
    For example ClassID might contain


    Now I need to find InstructorID where classID matches all the value in the above list.
    I am using this query

    Dim assSQL = "Select InstructorID from ClassInstructors where ClassID = @P0"
                For i = 1 To classIDs.Count - 1
                    assSQL &= " UNION Select InstructorID from ClassInstructors where ClassID = @P" & i.ToString
                Dim assCMD As New SqlCommand(assSQL)
                For i = 0 To classIDs.Count - 1
                    assCMD.Parameters.Add(New SqlParameter With {.ParameterName = "@P" & i.ToString, .SqlDbType = SqlDbType.VarChar, .Size = 50, .Value = classIDs(i)})
    But the problem is the query is returning InstructorID where ClassID matches any of the ClassIDs. I want it to return Instructor ID where ClassID matches all of the ClassIDs in the string.

    Can someone help with this?

  2. #2
    Join Date
    Sep 2006
    Surrey, UK
    Provided Answers: 2
    Not entirely sure what you're asking - it sounds like you're looking for multiple values in a single field.
    Could you post some sample data of the table, the passed list and what you expect to see returned?
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts