I want my users to input a query, say "milk cheese or sprite" but I am unsure of how I need to parse it out and what special considerations I need to make for it...
Does anyone know of any prewritten packages that will format the query correctly before i send it off to my stored procedure? or should i just not worry about it at all and send the text straight to the SP
If you want to users to input query string,you can write a class to deal with this and define some limitations to the query string,or you will get errors when you send them to SP.|||Full-text functionalities are good choice For example you can use CONTAINS predicate, for example:
SELECT ProductName
FROM Products
WHERE CONTAINS(ProductName, ' "sasquatch ale" OR "steeleye stout" ')
GO
So we can see we just need to properly format the input string. For more information about CONTAINS, you can refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ca-co_2y2h.asp
|||Well i understand how to use full text searching, I am more looking for a parser to read in the query from the textbox and reformat it so it is a properly formatted query to go to the database
Say they type "milk 2%" Cheese OR Sprite
I need the parser to take that and convert it to ["milk 2%" AND Cheese OR Sprite] and take out any crap they may put in it
The quick place is C# string literals under Verbatim but since you need (") with the Verbatim there are some restrictions using double qoutes with the Verbatim. So I think you can use C# string literal to get the part you want and Regex or Validator to filter out what you don't need. Try the links below to get started. And in the database look up ANSI SQL Qouted Identifiers and Delimiters in SQL Server BOL (books online). Hope this helps.
http://www.c-sharpcorner.com/1/verbatim_literals.asp
http://blogs.msdn.com/gusperez/archive/2005/08/10/450257.aspx
No comments:
Post a Comment