“TruckGrossWeight”运算符后的数据表缺少操作数

时间:2014-10-24 15:46:27

标签: c# datatable datatable.select

我有一个数据表,我想分配选择查询。但是会弹出以下错误:"语法错误:在&TruckHrossWeight'之后缺少操作数。操作"

DataRow[] drs = dataTableForDropDowns
 .Select("LNGFuelAvailability=" + drpdwnlst_LNGFuelAvailability.SelectedValue + " " +
         "TruckGrossWeight=" + drpdwnlst_TruckGrossCombinedWeight.SelectedValue + "");

所选值的值( int )是:

drpdwnlst_LNGFuelAvailability.SelectedValue= 5
drpdwnlst_TruckGrossCombinedWeight.SelectedValue = 2

1 个答案:

答案 0 :(得分:1)

尝试以下

DataRow[] drs = dataTableForDropDowns.Select("LNGFuelAvailability = "+drpdwnlst_LNGFuelAvailability.SelectedValue+ " AND TruckGrossWeight = "+drpdwnlst_TruckGrossCombinedWeight.SelectedValue);

语法应如下所示

DataRow[] results = table.Select("A = foo AND B = bar");

DataRow[] results = table.Select("A = foo OR B = bar");