Passing checklist to SQL stored procedure

I have a vb.net program that has a checked list box.  When the program is run, the user can select one or more of the batches that are listed in the box.  The program then runs and includes this code:

cmd.CommandText = "UPDATE PCT_PROD_BATCHING SET STATUS = 2, DATETIME_BATCHED = '" & dtDate & "' WHERE BATCH_NUMBER IN (" & String.Join(",", clbBatches.CheckedItems) & ")"
        cmd.ExecuteNonQuery()

I get this error:

The multi-part identifier "System.Windows.Forms.CheckedListBox" could not be bound.
Invalid column name 'CheckedItemCollection'.

I have used this same code in other applications and it has worked, but it is not working here.  How can I correct the problem?
T HoecherlDeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Máté FarkasDatabase Developer and AdministratorCommented:
First of all try to print somehow the SQL command you want to execute:
MsgBox cmd.CommandText

Open in new window


So CheckedItems property of CheckedListBox component returns a CheckedItemCollection object which is a subset of Items propery.
You need to enumerate on this collection and extract the name of each item and concatenate into the CommandText.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.