Query validation using C#

后端 未结 4 1701
北荒
北荒 2020-12-06 00:40

I am looking for a query validator in C#, which allows me to parse the SQL text from a textbox and verify whether it\'s correct or not before sending it for execution (MS SQ

4条回答
  •  [愿得一人]
    2020-12-06 00:57

    Set your query to sql with this hint:

    set PARSEONLY  on
    

    It just checks your query and returns, like this:

    set PARSEONLY  on
    select * from tablea
    

    Returns no exception.

    While

    set PARSEONLY  on
    select * f rom tablea
    

    returns

    Msg 102, Level 15, State 1, Line 2
    Incorrect syntax near 'f'.
    

提交回复
热议问题