Solved

Create String For SQL Query Parameter From CheckedListBox Selected Items

Posted on 2009-05-12
3
416 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 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