private void button1_Click(object sender, EventArgs e) { TextReader rdr = new StringReader(textBox1.Text); IList <ParseError> errors = null; TSql110Parser parser = new TSql110Parser(true); TSqlFragment tree = parser.Parse(rdr, out errors); foreach (ParseError err in errors) { Console.WriteLine(err.Message); } MyVisitor checker = new MyVisitor(); tree.Accept(checker); if (false == checker.containsOnlySelects) { MessageBox.Show("The code contains something other than SELECT statements!"); } else { MessageBox.Show("Looks ok!"); } rdr.Dispose(); }
private void button1_Click(object sender, EventArgs e) { using (var rdr = new StringReader(textBox1.Text)) { IList <ParseError> errors = null; var parser = new TSql150Parser(true, SqlEngineType.All); var tree = parser.Parse(rdr, out errors); foreach (ParseError err in errors) { Console.WriteLine(err.Message); } MyVisitor checker = new MyVisitor(); tree.Accept(checker); if (checker.containsOnlySelects) { MessageBox.Show("Looks ok!"); } else { MessageBox.Show("The code contains something other than SELECT statements!"); } } }