请教高手,我有两个DropdownList,分别是1和2,DropdownList1与数据库table的列a对应,DropdownList2的值是一个区间,为2000-3000;
  3000-4000;
  4000-5000;
  >5000;与列price对应,下面的查询语句错在哪里?急等,谢谢
      int[] breaks = DropDownList2.SelectedValue.Split(new char[]{'-'});
      string queryString = "select a,price from table where a='" + DropDownList1.SelectedValue + " ' or price >= {0} and price<={1}",breaks[0], breaks[1];

解决方案 »

  1.   

    DropDownList2.SelectedValue.Split('-'); 
      

  2.   

    没看到 >5000int[] breaks = DropDownList2.SelectedValue.Contains("-")?DropDownList2.SelectedValue.Split(new char[]{'-'}):DropDownList2.SelectedValue.Split(new char[]{'>'}); string queryString = string.Format("select a,price from table where a='{0}' or price >= {1} ", DropDownList1.SelectedValue , breaks[0]);
    if(DropDownList2.SelectedValue.Contains("-"))
    {
       queryString = string.Format("{0} and price <={1}",queryString , breaks[1]);
    }
      

  3.   

    楼上的大侠,问题解决了,不过
    string queryString = string.Format("select a,price from table where a='{0}' or price >= {1} ", DropDownList1.SelectedValue , breaks[0]); 
     中的or要改成and才能得到我要的结果;非常感谢你,祝你平安夜幸福快乐
      

  4.   

    2楼的lihuinihao6315,谢谢你的参与,也祝你平安夜快乐