?
Solved

Create String For SQL Query Parameter From CheckedListBox Selected Items

Posted on 2009-05-12
3
Medium Priority
?
426 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

Technology Partners: 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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

777 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