How can I validate SQL Script before using SQL 2.0 and c #?
If the SQL is not valid then I want to return the error rows.
If you are creating an appliance that connects the user with some SQL code and you If you want to validate the code using the C # code before execution on the SQL # server, then you can create a method like this:
using Microsoft.Data.Schema.ScriptDom Tax; Using Microsoft.Data.Schema.ScriptDom.Sql; Public category SqlParser {Public listing & lt; String & gt; Parse (string sql) {TSql100Parser parser = new TSql100Parser (wrong); IScriptFragment fragment; IList & LT; ParseError & gt; Errors; Piece = parser Purse (new stringreader (SQL), outside errors); If (errors! = Null & amp; errors; calculation & gt; 0) {list & lt; String & gt; Error list = new list & lt; String & gt; (); Foreach (error in errors) {errorList.Add (error.Message); } Return error list; } Return tap; }}
Comments
Post a Comment