C#组合查询小Demo

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        string Sql = "select * from T_AttWorkers";
        public Form1()
        {
            InitializeComponent();
            this.InitalList();

        }

        private void InitalList()
        {
            this.listBox1.Items.Add("编号");
            this.listBox1.Items.Add("姓名");

            this.listBox2.Items.Add("等于");
            this.listBox2.Items.Add("不等于");

            this.textBox1.Text = Sql;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Sql += " where ";
            Sql += "WorkerId = ";
            Sql += this.comboBox1.Text.Trim();

            this.textBox1.Text = Sql;
        }
    }
}
原文地址:https://www.cnblogs.com/SuperLady/p/5709823.html