• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 58
  • Last Modified:

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?
0
T Hoecherl
Asked:
T Hoecherl
1 Solution
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now