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

SQL Several Selected Tree Nodes?

I'm loading a Listview based on SQL query of more than one TreeView SelectedNode(s), but unsure how to procede. I have checkboxes in the Treeview to allow multiple selections. I can easily build a query based on just one TreeView Node like so:  "Select Distinct * From WinLogs Where ComputerName = '" + treeView1.SelectedNode.Text + "'";
1 Solution
You can say:
"Select Distinct * From WinLogs Where ComputerName IN (" + selectedNodes + ")";
Where selectedNodes is the Text of selected nodes, single-quoted and comma-separated.
Example: "'comp1', 'comp2', 'comp3'"
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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