Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Create String For SQL Query Parameter From CheckedListBox Selected Items

Posted on 2009-05-12
3
Medium Priority
?
428 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
srikanthreddyn143 earned 2000 total points
ID: 24366874
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
ID: 24368309
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
ID: 24368908
Can you show me the code?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

618 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