Obtaining Information About a Result Set Using the GetSchemaTable Method

Get information about a result set using the GetSchemaTable method.

  1. Declare and initialize a connection object:

    For C#:

    AseConnection conn = new AseConnection(
       c_connStr );

    For Visual Basic .NET:

    Dim conn As New AseConnection( _
       c_connStr )
  2. Open the connection:

    For C#:

    conn.Open();

    For Visual Basic .NET:

    conn.Open()
  3. Create an AseCommand object with the Select statement you want to use. The schema is returned for the result set of this query:

    For C#:

    AseCommand cmd = new AseCommand(
       "SELECT * FROM authors", conn );

    For Visual Basic .NET:

    Dim cmd As New AseCommand( _
       "SELECT * FROM authors", conn )
  4. Create an AseDataReader object and execute the Command object you created:

    For C#:

    AseDataReader dr = cmd.ExecuteReader();

    For Visual Basic .NET:

    Dim dr As AseDataReader = cmd.ExecuteReader()
  5. Fill the DataTable with the schema from the data source:

    For C#:

    DataTable
    schema = dr.GetSchemaTable();

    For Visual Basic .NET:

    Dim schema As DataTable = _
       dr.GetSchemaTable()
  6. Close the AseDataReader and AseConnection objects:

    For C#:

    dr.Close();
    conn.Close();

    For Visual Basic .NET

    dr.Close()
    conn.Close()
  7. Bind the DataTable to the grid on the window:

    For C#:

    dataGrid.DataSource = schema;

    For Visual Basic .NET:

    dataGrid.DataSource = schema