dotConnect for MySQL Documentation
Devart.Common Namespace / DbDataTable Class
Members Example

In This Topic
    DbDataTable Class
    In This Topic
    The DbDataTable class represents a single object that provides all of the functionality needed to retrieve and manipulate data from a data source. The DbDataTable class is built using existing ADO.NET components.
    Syntax
    Remarks

    The DbDataTable class extends the System.Data.DataTable class to provide a single object that can be used to access and update data from a data source. When a DbDataTable is created, the default values of its constituent parts are set to reasonable defaults, meaning that the programmer can create a single object and immediately use it to retrieve and manipulate data from a data source. It allows to cut down the size of the written code.

    The DbDataTable class is designed to employ both connected and disconnected data access models. It also provides functionality for asynchronous fill operations.

    The DbDataTable class can be fully adjusted at design-time. You may retrieve data at design-time from a data source if you set Active property to true.

    Note: This class is not available in .NET Standard 1.3 compatible assembly. It is available only in the assembly for full .NET Framework and .NET Standard 2.0 compatible assemblies.

    For more information on advanced features of DbDataTable please refer to topic DataTable Advanced Features.

    Example
    This sample shows how to use DbDataTable. The routine accepts DbTable-compatible object and IDbConnection implementor object as parameters. After SQL query text has been set, the data is retrieved from the table.
    static void UseDataTable(DbDataTable myDataTable, IDbConnection myConnection)
    {
      myDataTable.Connection = myConnection;
      myDataTable.SelectCommand = myConnection.CreateCommand();
      myDataTable.SelectCommand.CommandText = "SELECT * FROM Test.Dept";
      try
      {
        myDataTable.Fill();
        myDataTable.Rows[1].Delete();
        myDataTable.Update();
        foreach(DataRow myRow in myDataTable.Rows)
        {
          foreach(DataColumn myCol in myDataTable.Columns)
          {
            Console.Write(myRow[myCol] + "\t");
          }
          Console.WriteLine();
        }
      }
      finally
      {
        myDataTable.Clear();
      }
    }
    Public Sub UseDataTable(ByVal myDataTable As DbDataTable, ByVal myConnection As IDbConnection)
      myDataTable.Connection = myConnection
      myDataTable.SelectCommand = myConnection.CreateCommand()
      myDataTable.SelectCommand.CommandText = "SELECT * FROM Test.Dept"
      Try
        myDataTable.Fill()
        myDataTable.Rows(1).Delete()
        myDataTable.Update()
        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.Clear()
      End Try
    End Sub
    Inheritance Hierarchy

    System.Object
       System.ComponentModel.MarshalByValueComponent
          System.Data.DataTable
             Devart.Common.DbDataTable
                Devart.Data.MySql.MySqlDataTable

    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