gridView模糊查詢,
搜索條件兩個,一個年份,一個建立者。建立者是模糊查詢。
我想不輸入建立者,只輸入年份,能找到當年所有的記錄。
現在問題是:
必須輸入年份和建立者才能搜索到記錄。
另:
該sql語句在資料庫中執行沒有問題。
select * from pubCostVersion where yearly=2007 and createby like '%%'
------解決方案--------------------
code=SQL]select * from pubCostVersion where (yearly=null or yearly=2007) and (createby like '%% ' or createby =null)[[/code]
------解決方案--------------------
- SQL code
select * from pubCostVersion where (yearly=null or yearly=2007) and (createby like '%% ' or createby =null) ------解決方案-------------------- 不用那麼麻煩.你用like就行了: SelectCommand="SELECT [Yearly], [Monthly], [isCale], [CreateBy], [CreateTime], [ModifyBy], [ModiFyTime] FROM [pubCostVersion] WHERE (([Yearly] like '%"+@Yearly+"%') AND (([CreateBy] LIKE '% " + @CreateBy + "% ')))" ------解決方案-------------------- SelectCommand="SELECT [Yearly], [Monthly], [isCale], [CreateBy], [CreateTime], [ModifyBy], [ModiFyTime] FROM [pubCostVersion] WHERE (([Yearly] = @Yearly) AND ((@CreateBy = '') or ([CreateBy] LIKE '% ' + @CreateBy + '% ')))" >
Bookmark the permalink ,來源:互聯網
沒有留言:
張貼留言