static public DataTable First_step(DataTable dt,double min,double max)
    {
        string uu = "Height  >  " + min.ToString()+" and Height<" +max.ToString();
        DataRow[] dtrows = dt.Select(uu);
        DataTable dt_right = dt.Clone();
        for (int i = 0; i < dtrows.Length; i++)
        {
            dt_right.ImportRow(dtrows[i]);
        }
        return dt_right;
      
    }
选择表格中Height 字段值在min和max之间的记录,请问,当设min=0,max=20的时候,怎么会选出来负值呢

解决方案 »

  1.   

    当设min=0,max=20的时候,看看你的uu是否对
      

  2.   

    Height  >  0 and Height<20
    这样对吗?
      

  3.   

    1.首先保证Height的类型时int2, min =0; max =20 的时候 
    看看 
    DataRow[] dtrows = dt.Select(uu); 
    dtrows 的长度,就是有没有纪录。 如上俩个条件都满足,你的代码是对的。小例子:  DataTable table = new DataTable("table");
                DataColumn c = new DataColumn("A",Type.GetType("System.Int32"));
                DataColumn c1 = new DataColumn("A2");
                DataColumn c2 = new DataColumn("A3", Type.GetType("System.Boolean"));
                
                table.Columns.Add(c);
                table.Columns.Add(c1);
                table.Columns.Add(c2);
                for (int i = 0; i < 22; i++)
                {
                    DataRow r = table.NewRow();
                    r[0] = i.ToString();
                    r[1] = "name" + i.ToString();
                    r[2] = true;
                    table.Rows.Add(r);            }
                int min = 0;
                int max = 20;
               string uu = "A  >  " + min.ToString()+" and A <" +max.ToString(); 
               DataRow[] dtrows = table.Select(uu);
               DataTable dt_right = table.Clone(); 
               for (int i = 0; i < dtrows.Length; i++) 
              { 
                dt_right.ImportRow(dtrows[i]); 
              } 
      

  4.   

    请问如果Height刚开始附值的时候是string,后面能改嘛