Results 1 to 2 of 2

Thread: Saving Checked Items in CheckedListBox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2008
    Posts
    105

    Saving Checked Items in CheckedListBox

    Hi!

    How can i use multiple items in my stored procedure?
    For example I checked 5 items in my CheckedListBox and iwant to use the ID's of the checked items to filter my record.


    This is my code:

    Dim strFilterGroup as String
    Dim o As Object

    For Each o In frm.chkListBoxEmployee.CheckedItems
    strFilterGroup = "EmployeeID = '" & o.GetKey & "'"
    Next

    For Each drow In dtSrc.Select(strFilterGroup)
    Dim drowNew As dsDataForExport.tblAttendanceRow

    drowNew = dsToDownload.tblAttendance.NewRow()
    drowNew.EmployeeID = drow("EmployeeID")
    drowNew.StartOfPeriod = drow("StartOfPeriod")
    drowNew.EndOfPeriod = drow("EndOfPeriod")
    drowNew.TimeKeeperID = drow("TimeKeeperID")
    dsToDownload.tblAttendance.Rows.Add(drowNew)
    Next

    in my dtSrc.Select i want to pass multiple id's there. How can i possibly do that?
    thanks!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Saving Checked Items in CheckedListBox

    Follow the "SQL IN Clause with Parameters" link in my signature.

    My code uses a DataAdapter, which I recommend you do too. If you really want to use a TableAdapter then I guess you can create an instance at run time and then set its SelectCommand.CommandText property, although I've never actually tried that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width