When multiple CheckedComboBoxEdit options are selected, there will be an extra space between the value and the value,

Source: Internet
Author: User

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 (",","','")

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.