开发者

C# Multiple Keywords Fulltext Freetext Parameterized Query

开发者 https://www.devze.com 2023-02-03 22:15 出处:网络
I have a SQL 2008 database with a fulltext catalog setup for one of my tables and the goal is to be able to conduct a freetext search against that table from an asp.net c# website where the freetext v

I have a SQL 2008 database with a fulltext catalog setup for one of my tables and the goal is to be able to conduct a freetext search against that table from an asp.net c# website where the freetext value could have multiple keywords. Using SQL Management Studio, I can manually run the queries such as:

SELECT * FROM KnowledgeFAQ_Answers WHERE FREETEXT ((Title, [Text]), 'application deadlines') Order By Rank() Over (Order By Title)

And everything works just fine. After I had my query I then created my data access code in my website and for the most part it works okay but in certain situations I have discrepancies. It seems that certain smaller words, when present in the search string, just returns an empty datareader; however, testing the same phrase directly in SQL Management Studio returns the results correctly. So for an example "admissions deadline" will work and return a reader with results but "has admissions 开发者_如何学Pythondeadline" suddenly returns nothing despite manually running the query producing results. Certain words, for no particular reason that I can see, cause 0 results but also produces no SQL errors... just returns the empty datareader. It seems like the sqlcommand object parses these specially somehow in a way that doesn't break the syntax but produces no matches. Does anyone have a working example of multiple keywords in a freetext query through a sqlcommand object and/or reasoning as to why this wont work?... at a total loss here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号