当前位置: 代码迷 >> C# >> 带checkbox的treevie控件与sql语句拼接的有关问题
  详细解决方案

带checkbox的treevie控件与sql语句拼接的有关问题

热度:79   发布时间:2016-05-05 04:12:04.0
带checkbox的treevie控件与sql语句拼接的问题
我有一个带checkbox的treevie控件,作为sql语句的查询条件,当treeview的checkbox选中的时候就要查询选中的那个checkbox表示的值,但是treeview的子节点很多,这个要怎么拼接才能够简单点啊?
select AreaName,foodClass,foodName,inputdate,producedata,validperiod,
SUM(foodamount) as 库存,foodunit ,Unitprice,(SUM(foodamount)*Unitprice) as newtotalprice 
from FoodRepertory_T
where  inputdate between '2014-01-01 0:00:00' and '2016-5-3' 
and outdate between '2014-01-01 0:00:00' and '2016-5-3'  
and    and foodClass = '肉禽1'  
or inputdate between '2014-01-01 0:00:00' and '2016-5-3' 
and    and foodClass = '肉禽2'
and outdate is null
 group by   AreaName,foodClass,foodName,producedata,validperiod,inputdate,foodunit ,Unitprice


foodClass就是treeview的可选值,我现在的思路是foreach treeview的所有节点,当选中的时候 把选中的
inputdate between '2014-01-01 0:00:00' and '2016-5-3' 
and outdate between '2014-01-01 0:00:00' and '2016-5-3'  
and    and foodClass = '肉禽1'  
or inputdate between '2014-01-01 0:00:00' and '2016-5-3' 
and    and foodClass = '肉禽2'
and outdate is null
 group by   AreaName,

重写一次,并拼接到sql语句中,这样感觉好麻烦啊!
------解决思路----------------------
引用:
Quote: 引用:

你贴的是一个sql查询语句.这跟存储过程没有任何关系.我也无从说起.可能是你的程序是通过存储过程来更新数据的.但是你的数据
表没有这个存储过程
在sql数据库中,把拼接“ +”  符号去掉就可以![email protected]

原来你是在考验我去.一会儿你把我给整晕了
  相关解决方案