dotConnect for SQLite Documentation
Devart.Common Namespace / DbDataTable Class / Open() Method
Example

In This Topic
    Open() Method
    In This Topic
    Fetches data and sets the Active property to true.
    Syntax
    'Declaration
     
    Public Sub Open() 
    public void Open()
    Remarks

    The Open method executes the SelectCommand, creates columns and fills rows with data. Depending on values of miscellaneous properties, DbDataTable fetches either all data or some subset. For example, when DbDataTable is connected to a grid, it requests only data required for rendering (FetchAll=false mode), or the whole recordset (FetchAll=true mode).

    For more information about DbDataTable fill capabilities please refer to descriptions of the following properties: FetchAll, MaxRecords, NonBlocking, QueryRecordCount, ReturnProviderSpecificTypes, StartRecord. The following methods also provide additional features: BeginFill, FillPage, FillSchema.

    Example
    The following example demonstrates how to use the Open() method.
    static void UseDataTable(DbDataTable myDataTable, DbCommand myCommand)
    {
      myCommand.CommandText = "SELECT * FROM Dept";
      myDataTable.SelectCommand = myCommand;
      try
      {
            myDataTable.FetchAll=true;
        myDataTable.Open();
        foreach(DataRow myRow in myDataTable.Rows)
        {
          foreach(DataColumn myCol in myDataTable.Columns)
          {
            Console.Write(myRow[myCol]+"\t");
          }
          Console.WriteLine();
        }
      }
      finally
      {
        myDataTable.Close();
      }
    }
    Public Sub UseDataTable(ByVal myDataTable As DbDataTable, ByVal myCommand As DbCommand)
      myCommand.CommandText = "SELECT * FROM Dept"
      myDataTable.SelectCommand = myCommand
      Try
            myDataTable.FetchAll=True
        myDataTable.Open()
        Dim myRow As DataRow
        Dim myCol As DataColumn
        For Each myRow In myDataTable.Rows
          For Each myCol In myDataTable.Columns
            Console.Write(myRow(myCol) & Chr(9))
          Next myCol
          Console.WriteLine()
        Next myRow
      Finally
        myDataTable.Close()
      End Try
    End Sub
    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