Solved

Create String For SQL Query Parameter From CheckedListBox Selected Items

Posted on 2009-05-12
3
409 Views
Last Modified: 2012-05-06
I have a CheckedListBox1 on my form that I would like to get all of the checked items to go into a textbox on my form set up like a sql in statement to pass to a query. so for example when the user checks 4 items in the list the textbox1 should look like ...

IN('myvalue1','myvalue2','myvalue3','myvalue4')

many thanks in advance
0
Comment
Question by:H-SC
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
srikanthreddyn143 earned 500 total points
Comment Utility
In the CheckBox check event

If Txtbox1.text = "" then
Txtbox1.text = "'" & Checkbox.selectedvalue & "'" & ","
Else
Txtbox1.text = Txtbox1.text & "'" & Checkbox.selectedvalue & "'" & ","
EndIf

Txtbox1.text = Txtbox1.Text.ToString().Remove(Txtbox1.Text.ToString().Length - 1, 1)


'When you are making SQL query ;  query = "IN (" & TxtBox1.Text & ")"
0
 
LVL 1

Author Comment

by:H-SC
Comment Utility
srikanthreddy,

for some reason I keep getting a compile error of the following -

Operator '&' is not defined for string "'" and type 'DataRowView'.

any suggestions
0
 
LVL 11

Expert Comment

by:srikanthreddyn143
Comment Utility
Can you show me the code?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now