CheckedListBox选择的项目到SQL

时间:2017-10-02 07:50:32

标签: vb.net

有没有办法从CheckedListBox获取所选项目列表以在SQL表达式中使用它?我为CheckedListBox填充了列名(.DisplayMember = "COLUMN_NAME", .ValueMember = "COLUMN_NAME"),并希望用户只选择要导出到Excel的列。我只需要选择例如Name, ID, Number来使用SELECT Name, ID, Number FROM ...

1 个答案:

答案 0 :(得分:0)

 If CheckedListBox.SelectedItems.Count <> 0 Then
     Dim columns = String.Join(",", CheckedListBox.CheckedItems.Cast(Of String))

     Dim query = String.Format("SELECT {0} FROM ..", columns)
     'Proceed
  Else
     'Prompt user to select columns
  End If