Active Query Builder 2 .NET Edition reference
SqlError Event (QueryBuilderControl)



Invoked on SQL text parsing error.
Syntax
'Declaration
 
Public Event SqlError As SqlErrorEvenHandler
'Usage
 
Dim instance As QueryBuilderControl
Dim handler As SqlErrorEvenHandler
 
AddHandler instance.SqlError, handler
public event SqlErrorEvenHandler SqlError
public: __event SqlErrorEvenHandler* SqlError
Remarks

You can pass an SQL query text to the QueryBuilder.SQL property and have it parsed and represented visually in the control. If the component fails to parse a query, it raises an exception. Alternate way to catch SQL parsing errors is to use the SqlError event. Having the SQLError event handler defined, the component will not raise an exception in this case, but fire the event instead.

The sql parameter is the SQL query text that failed to parse. The error parameter is the error message string. The errorToken parameter is the erroneous token string. The errorTokenPos parameter addresses the erroneous token in the SQL query text.

            public struct Pos
            {
                public int pos;  // token position in the source text (starting at 0)
                public int col;  // token column (starting at 0)
                public int line; // token line (starting at 1)
            }
            

You can control the behavior of the component on parsing unknown types of SQL statements or on parsing queries with unknown objects using the QueryBuilder.BehaviorOptions properties: AllowSleepMode, ParsingErrorOnUnknownObjects.

Example
            private void queryBuilder1_SqlError(object sender, string sql, string error, string errorToken, Pos errorTokenPos)
            {
                MessageBox.Show(string.Format(
                    "Unexpected token \"{0}\" at line {1}, column {2}",
                    errorToken, errorTokenPos.line, errorTokenPos.col));
            }
            
See Also

Reference

QueryBuilderControl Class
QueryBuilderControl Members

 

 


© Copyright 2005-2012 ActiveDBSoft. All rights reserved.

Send Feedback