开发者

Dynamic FULL TEXT CONTAINSTABLE queries advice

开发者 https://www.devze.com 2023-04-04 13:29 出处:网络
I am currently working on a project where I need to build dynamic CONTAINSTABLE queries. I have code in place that does something like:

I am currently working on a project where I need to build dynamic CONTAINSTABLE queries. I have code in place that does something like:

public string BuildQuery(string searchTerms)
{
    searchTerms= searchTerms.Replace("'", "''");

    string[] words = searchTerms.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

    // Here I concatenate all the words into a string separated by AND and pass that to a SQL UDF
}
开发者_Python百科

My question is in regards to cleaning the search terms from characters that can break the SQL query. Currently I am only removing the "'" character since this will break the dynamic query.

Are there any other characters I should think of that can break the query?

Thanks


ASCII Key Combos will definitely break this dynamic query ,like Õ Ž etc

0

精彩评论

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

关注公众号