正在做的一个查询系统(winform)想实现这样的功能,将listBox中的选中的查询关键字赋给textBox1,根据comboBox中选择的查询条件(大于,等于,小于)以及textBox2中的内容,进行相关的查询求各位前辈帮我理清下思路~大概的说明下程序流程和设计思想就行

解决方案 »

  1.   

    这个很简单的查询语句就写上select * from 表 A where 1=1  
    然后根据条件去拼接下边的字符串。
    比如 and 学好>10
      

  2.   

    private void Listbox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                if (Listbox1.SelectedItem != null)
                {
                    Textbox1.Text = Listbox1.SelectedItem.ToString(); 
                }
            }
    再select * from tb where 条件
      

  3.   


    sql语句我懂我想问的是实现的办法难道要用21条if语句?7个关键字和3个查询条件
    if(textBox1.text=="学号"&&comboBox.text=="等于")
    {
    string sql="select * from table where id='"+textBox2.text+"'";
    sqlcommand cmd=sqlcommand(sql,conn);
    cmd.ExecuteScalar();
    }
    if(textBox1.text=="学号"&&comboBox.text=="大于")
    {
    string sql="select * from table where id>'"+textBox2.text+"'";
    sqlcommand cmd=sqlcommand(sql,conn);
    cmd.ExecuteScalar();}
    .....
    .....
    .....
      

  4.   


    额,其实我想问的是,如何根据textBox1、comboBox、textBox2的值,判断进行何种查询