dotConnect for Salesforce Marketing Cloud Documentation
Devart.Common Namespace / DbDataReaderBase Class / GetSchemaTable Method
Example

In This Topic
    GetSchemaTable Method
    In This Topic
    Returns a System.Data.DataTable that describes the column metadata of the DbDataReaderBase.
    Syntax
    'Declaration
     
    Public Overrides Function GetSchemaTable() As DataTable
    public override DataTable GetSchemaTable()

    Return Value

    A System.Data.DataTable that describes the column metadata.
    Remarks

    The GetSchemaTable method returns metadata about each column in the following order:

    DataReader Column Description
    ColumnName The name of the column; this might not be unique. If the column name cannot be determined, a null value is returned. This name always reflects the most recent naming of the column in the current view or command text.
    ColumnOrdinal The ordinal of the column. This is zero for the bookmark column of the row, if any. Other columns are numbered starting with 1. This column cannot contain a null value.
    ColumnSize The maximum possible length of a value in the column. For columns that use a fixed-length data type, this is the size of the data type.
    NumericPrecision If System.Data.DbType is a numeric data type, this is the maximum precision of the column. The precision depends on the definition of the column. If System.Data.DbType is not a numeric data type, this is a null value.
    NumericScale If System.Data.DbType is Decimal, the number of digits to the right of the decimal point. Otherwise, this is a null value.
    DataType Maps to the .Net Framework type of the column.
    ProviderType The indicator of the column's data type.
    IsLong true if the column contains a BLOB that contains very long data.
    AllowDBNull true if the consumer can set the column to a null value. Otherwise, false. A column may contain null values, even if it cannot be set to a null value.
    IsReadOnly true if the column can not be modified; otherwise, false.
    IsRowVersion Set if the column contains a persistent row identifier that cannot be written to, and has no meaningful value except to identity the row.
    IsUnique true: No two rows in the base table-the table returned in BaseTableName-can have the same value in this column. IsUnique is guaranteed to be true if the column constitutes a key by itself or if there is a constraint of type UNIQUE that applies only to this column. false: The column can contain duplicate values in the base table.The default for this column is false.
    IsKey true: The column is one of a set of columns in the rowset that, taken together, uniquely identify the row. The set of columns with IsKey set to true must uniquely identify a row in the rowset. There is no requirement that this set of columns is a minimal set of columns. This set of columns may be generated from a base table primary key, a unique constraint or a unique index. false: The column is not required to uniquely identify the row.
    To get the primary key information, including whether a field is part of a primary key and whether it is an AutoIncrement field, you should set the CommandBehavior.KeyInfo parameter of the ExactTargetCommand.ExecuteReader() method when getting your data reader.
    IsAutoIncrement true if the column assigns values to new rows in fixed increments; otherwise, false. The default value for this column is false.
    BaseSchemaName The name of the schema in the database that contains the column. NULL if the base catalog name cannot be determined. The default for this column is a null value.
    BaseCatalogName The name of the catalog in the data store that contains the column. NULL if the base catalog name cannot be determined. The default value for this column is a null value.
    BaseTableName The name of the table or view in the data store that contains the column. A null value if the base table name cannot be determined. The default value of this column is a null value.
    BaseColumnName The name of the column in the data store. This might be different than the column name returned in the ColumnName column if an alias was used. A null value if the base column name cannot be determined or if the rowset column is derived, but not identical to, a column in the data store. The default value for this column is a null value.
    IsAliased true if the column name is an alias; otherwise, false.
    IsExpression true if the column is an expression; otherwise, false.

    Note: if you want metadata columns to return the correct information, you must call the Command.ExecuteReader(CommandBehavior) method with the behavior parameter set to KeyInfo. Otherwise, some of the schema table columns may return null, default, or incorrect data.

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

    Example
    static void GetSchemaFromReader(ExactTargetConnection myConnection) {
      ExactTargetCommand cmd = new ExactTargetCommand("SELECT * FROM Email");
      cmd.Connection = myConnection;
      myConnection.Open();
      try {
        ExactTargetDataReader reader = cmd.ExecuteReader(CommandBehavior.KeyInfo);
    
        DataTable dt = reader.GetSchemaTable();
        //...
    
        reader.Close();
      }
      finally {
        myConnection.Close();
      }
    }
    Shared Sub GetSchemaFromReader(ByVal myConnection As ExactTargetConnection)
      Dim cmd As New ExactTargetCommand("SELECT * FROM Email")
      cmd.Connection = myConnection
      myConnection.Open()
      Try
        Dim reader As ExactTargetDataReader = cmd.ExecuteReader(CommandBehavior.KeyInfo)
        Dim dt As DataTable = reader.GetSchemaTable
        '...
    
        reader.Close()
      Finally
        myConnection.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