dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlSelectStatement Class / Parse(String,ParserBehavior) Method
The statement to parse.
One of the Devart.Common.ParserBehavior values. Determines what parts of the statement to analyze.
Example

In This Topic
    Parse(String,ParserBehavior) Method
    In This Topic
    Converts the specified SELECT statement to a MySqlSelectStatement object.
    Syntax
    'Declaration
     
    Public Shared Function Parse( _
       ByVal text As String, _
       ByVal behavior As ParserBehavior _
    ) As MySqlSelectStatement
    public static MySqlSelectStatement Parse( 
       string text,
       ParserBehavior behavior
    )

    Parameters

    text
    The statement to parse.
    behavior
    One of the Devart.Common.ParserBehavior values. Determines what parts of the statement to analyze.

    Return Value

    A MySqlSelectStatement object that represents the specified SELECT statement.
    Example
    The following example demonstrates how to use the Parse(String,ParserBehavior) method.
    static void PrintTables(string query) {
    
      MySqlSelectStatement stmt = MySqlSelectStatement.Parse(query, ParserBehavior.Tables);
    
      Console.WriteLine("{0} tables:", stmt.Tables.Count);
      foreach (SelectTable st in stmt.Tables)
        Console.WriteLine("Table {0} in {1}", st.Name, st.Schema);
    }
    
    PrintTables("SELECT TABLE_NAME FROM information_schema.`TABLES` ORDER BY TABLE_NAME");
    PrintTables("SELECT ENAME, JOB, DNAME FROM test.emp, test.dept WHERE emp.DEPTNO = dept.DEPTNO");
    PrintTables("SELECT query_time, Execute_priv, body FROM mysql.slow_log, mysql.host, mysql.event");
    
    
    //Output
    //1 tables:
    //Table `TABLES` in information_schema
    //2 tables:
    //Table emp in test
    //Table dept in test
    //3 tables:
    //Table slow_log in mysql
    //Table host in mysql
    //Table event in mysql
    Private Shared Sub PrintTables(ByVal query As String)
      Dim stmt As MySqlSelectStatement = MySqlSelectStatement.Parse(query, ParserBehavior.Tables)
      Console.WriteLine("{0} tables:", stmt.Tables.Count)
      Dim st As SelectTable
      For Each st In stmt.Tables
        Console.WriteLine("Table {0} in {1}", st.Name, st.Schema)
      Next
    End Sub
    
    Form1.PrintTables("SELECT TABLE_NAME FROM information_schema.`TABLES` ORDER BY TABLE_NAME")
    Form1.PrintTables("SELECT ENAME, JOB, DNAME FROM test.emp, test.dept WHERE emp.DEPTNO = dept.DEPTNO")
    Form1.PrintTables("SELECT query_time, Execute_priv, body FROM mysql.slow_log, mysql.host, mysql.event")
    
    'Output
    '1 tables:
    'Table `TABLES` in information_schema
    '2 tables:
    'Table emp in test
    'Table dept in test
    '3 tables:
    'Table slow_log in mysql
    'Table host in mysql
    'Table event in mysql
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also