首页 > 代码库 > 查询多列数据时用这种方法查询

查询多列数据时用这种方法查询

 1  private void cbbType_SelectedIndexChanged(object sender, EventArgs e) 2         { 3             //清空DN列 4             cbbDn.Items.Clear(); 5             //字段清除 6             FieldListSaddle.Clear(); 7             //加入字段 8             FieldListSaddle.Add("Baojiao,Drawing,Table,Ribs,Type1,HasPad"); 9             //定义查询条件10             string where = string.Format("DnX < {0} and DnD >= {0} and Type2 = ‘{1}‘", DI, cbbType.Text);11             //按照条件查询表12             tbBiao = GetAccessData(TypeName, FieldListSaddle, where);13             //如果表中有两列数据则需要循环查找并添加14             for (int i = 0; i < tbBiao.Rows.Count; i++)15             {16                 //表名等于第一行数据的表17                 string TableName = (tbBiao.Rows[i]["Table"]).ToString();18                 //查询出DN表放入内存19                 tbDn = GetAccessData(TableName);20                 //查询出符合DN的那一列21                 DnList = tbDn.AsEnumerable().Select(p => p.Field<double>("DN").ToString()).Distinct().ToList();22                 //加入控件中23                 cbbDn.Items.AddRange(DnList.ToArray());24             }25         }
View Code

 

查询多列数据时用这种方法查询