2014-01-29 44 views
0

這裏是我的查詢:多個或/與。搜索條款無效

 cs.SqlWhereClause = "([IsDiscontinued] = 0 AND [Visible] = 1 AND [ProductAvailableForSale] = 1) AND "; 
     cs.SqlWhereClause += "[LongDescription] like '%ct.%tw.%' "; 
     cs.SqlWhereClause += "OR ([LongDescription] like '%\"' "; 
     cs.SqlWhereClause += "OR [LongDescription] like '%ct.%' "; 
     cs.SqlWhereClause += "OR [LongDescription] like '%14k%' "; 
     cs.SqlWhereClause += "OR [LongDescription] like '%18k%' "; 
     cs.SqlWhereClause += "OR [LongDescription] like '%10k%' "; 
     cs.SqlWhereClause += "OR [LongDescription] like '%12k%' "; 
     cs.SqlWhereClause += "OR [LongDescription] like '%cttw%')"; 

這裏是我想要返回什麼內容:

項目是:不停產,可見,和可供出售

AND

項目,其longdescriptions是LIKE '%ct.tw.%' 或像 '%克拉%' 等。

加入價格調整匯率在第一個OR之後和最後一個OR之後的合併給我錯誤。我一直無法調試它。有任何想法嗎?

+0

什麼是錯誤信息? –

回答

1

您應該在第一個或第一個之前添加第一個參數。像這樣:

cs.SqlWhereClause = "([IsDiscontinued] = 0 AND [Visible] = 1 AND [ProductAvailableForSale] = 1) AND "; 
cs.SqlWhereClause += "([LongDescription] like '%ct.%tw.%' "; 
cs.SqlWhereClause += "OR [LongDescription] like '%\"' "; 
cs.SqlWhereClause += "OR [LongDescription] like '%ct.%' "; 
cs.SqlWhereClause += "OR [LongDescription] like '%14k%' "; 
cs.SqlWhereClause += "OR [LongDescription] like '%18k%' "; 
cs.SqlWhereClause += "OR [LongDescription] like '%10k%' "; 
cs.SqlWhereClause += "OR [LongDescription] like '%12k%' "; 
cs.SqlWhereClause += "OR [LongDescription] like '%cttw%')";