zoukankan      html  css  js  c++  java
  • CheckedComboBoxEdit 多选时,值与值之间会多出一个空格

    测试代码:

     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("小明");
    12             list.Add("小红");
    13             list.Add("小李");
    14             this.checkedComboBoxEdit1.Properties.DataSource = list;
    15         }
    16 
    17         private void checkedComboBoxEdit1_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     }

    效果:

    对checkedComboBoxEdit的多值进行SQL查询时,查询中使用IN语句,IN里面第一个条件后面的所有条件的前面都会多出一个空格,导致查询不正确

    需将空格去掉再传入SQL查询:

    Replace(",","','") 改为  Replace(", ","','")
  • 相关阅读:
    XML 验证器
    XML 浏览器支持
    XML 元素
    查看 XML 文件
    XML 属性
    Android入门之Activity四种启动模式
    XML 简介
    XML 语法规则
    [Android]Thread线程入门3多线程
    XML 验证
  • 原文地址:https://www.cnblogs.com/huangchuxian/p/7808325.html
Copyright © 2011-2022 走看看