When multiple CheckedComboBoxEdit options are selected, there will be an extra space between the value and the value,
Test code:
1 public partial class Form1: Form 2 {3 public Form1 () 4 {5 InitializeComponent (); 6} 7 8 private void Form1_Load (object sender, EventArgs e) 9 {10 List <string> list = new List <string> (); 11 list. add ("James"); 12 list. add ("red"); 13 list. add ("Xiao Li"); 14 this. checkedComboBoxEdit1.Properties. dataSource = list; 15} 16 17 private void checkedcomboboxedit#editvaluechanged (object sender, EventArgs e) 18 {19 if (This. checkedComboBoxEdit1.Text! = "") 20 {21 this. textEdit1.Text = this. checkedComboBoxEdit1.Text; 22 this. textEdit2.Text = string. format ("select * from tableA where name in ('{0}')", this. checkedComboBoxEdit1.Text ).Replace (",","','"); 23} 24} 25}
Effect:
When performing an SQL query on the multi-value of checkedComboBoxEdit, The IN statement is used IN the query. A space is added before all the conditions after the first condition IN, leading to incorrect query.
You need to remove spaces before passing in the SQL query:
Replace (",", "','") to Replace (",","','")