OdbcDataReader.GetSchemaTable Método
Definição
Retorna um DataTable que descreve os metadados da coluna do OdbcDataReader.Returns a DataTable that describes the column metadata of the OdbcDataReader.
public:
override System::Data::DataTable ^ GetSchemaTable();
public:
virtual System::Data::DataTable ^ GetSchemaTable();
public override System.Data.DataTable GetSchemaTable ();
public override System.Data.DataTable? GetSchemaTable ();
public System.Data.DataTable GetSchemaTable ();
override this.GetSchemaTable : unit -> System.Data.DataTable
abstract member GetSchemaTable : unit -> System.Data.DataTable
override this.GetSchemaTable : unit -> System.Data.DataTable
Public Overrides Function GetSchemaTable () As DataTable
Public Function GetSchemaTable () As DataTable
Retornos
Um DataTable que descreve os metadados de coluna.A DataTable that describes the column metadata.
Implementações
Exceções
O OdbcDataReader está fechado.The OdbcDataReader is closed.
Comentários
O GetSchemaTable método retorna metadados sobre cada coluna na seguinte ordem:The GetSchemaTable method returns metadata about each column in the following order:
| Coluna DataReaderDataReader column | DescriçãoDescription |
|---|---|
| ColumnNameColumnName | O nome da coluna; Isso pode não ser exclusivo.The name of the column; this might not be unique. Se o nome da coluna não puder ser determinado, um valor nulo será retornado.If the column name cannot be determined, a null value is returned. Esse nome sempre reflete a nomenclatura mais recente da coluna na exibição atual ou no texto do comando.This name always reflects the most recent naming of the column in the current view or command text. |
| ColumnOrdinalColumnOrdinal | O ordinal com base em zero da coluna.The zero-based ordinal of the column. Esta coluna não pode ter um valor nulo.This column cannot contain a null value. |
| ColumnSizeColumnSize | O comprimento máximo possível de um valor na coluna.The maximum possible length of a value in the column. Para colunas que usam um tipo de dados de comprimento fixo, esse é o tamanho do tipo de dados.For columns that use a fixed-length data type, this is the size of the data type. |
| NumericPrecisionNumericPrecision | Se DbType for um tipo de dados numérico, essa será a precisão máxima da coluna.If DbType is a numeric data type, this is the maximum precision of the column. A precisão depende da definição da coluna.The precision depends on the definition of the column. Se DbType não for um tipo de dados numérico, não use os dados nesta coluna.If DbType is not a numeric data type, do not use the data in this column. Se o driver ODBC subjacente retornar um valor de precisão para um tipo de dados não numérico, esse valor será usado na tabela de esquema.If the underlying ODBC driver returns a precision value for a non-numeric data type, this value is used in the schema table. |
| NumericScaleNumericScale | Se DbType for Decimal , o número de dígitos à direita do ponto decimal.If DbType is Decimal, the number of digits to the right of the decimal point. Caso contrário, esse é um valor nulo.Otherwise, this is a null value. Se o driver ODBC subjacente retornar um valor de precisão para um tipo de dados não numérico, esse valor será usado na tabela de esquema.If the underlying ODBC driver returns a precision value for a non-numeric data type, this value is used in the schema table. |
| Tipo de dadosDataType | Mapeia para o tipo de Common Language Runtime de DbType .Maps to the common language runtime type of DbType. |
| ProviderTypeProviderType | O tipo de driver subjacente.The underlying driver type. |
| IsLongIsLong | true se a coluna contiver um BLOB (objeto binário longo) que contenha dados muito longos.true if the column contains a Binary Long Object (BLOB) that contains very long data. A definição de dados muito longos é específica do driver.The definition of very long data is driver-specific. |
| AllowDBNullAllowDBNull | true Se o consumidor puder definir a coluna como um valor nulo ou se o driver não puder determinar se o consumidor pode definir a coluna como um valor nulo.true if the consumer can set the column to a null value or if the driver cannot determine whether the consumer can set the column to a null value. Caso contrário, false.Otherwise, false. Uma coluna pode conter valores nulos mesmo se não puder ser ajustada para um valor nulo.A column may contain null values, even if it cannot be set to a null value. |
| IsReadOnlyIsReadOnly | true se a coluna não puder ser modificada; caso contrário false .true if the column cannot be modified; otherwise false. |
| IsRowVersionIsRowVersion | Defina se a coluna contém um identificador de linha persistente que não pode ser gravado e que não tem valor significativo, exceto para identificar a linha.Set if the column contains a persistent row identifier that cannot be written to, and has no meaningful value except to identity the row. |
| IsUniqueIsUnique | true: Não há duas linhas na tabela base (a tabela retornada em BaseTableName) pode ter o mesmo valor nessa coluna.true: No two rows in the base table (the table returned in BaseTableName) can have the same value in this column. IsUnique é garantido true se a coluna representa uma chave por si só ou se há uma restrição do tipo Unique que se aplica somente a essa coluna.IsUnique is guaranteed to be true if the column represents a key by itself or if there is a constraint of type UNIQUE that applies only to this column.false: A coluna pode conter valores duplicados na tabela base.false: The column can contain duplicate values in the base table. O padrão para essa coluna é false .The default for this column is false. |
| IsKeyIsKey | true: A coluna é um de um conjunto de colunas no conjunto de linhas que, em conjunto, identifica exclusivamente a linha.true: The column is one of a set of columns in the rowset that, taken together, uniquely identify the row. O conjunto de colunas com IsKey definido como true deve identificar exclusivamente uma linha no conjunto de linhas.The set of columns with IsKey set to true must uniquely identify a row in the rowset. Não há nenhum requisito de que esse conjunto de colunas seja um conjunto mínimo de colunas.There is no requirement that this set of columns is a minimal set of columns. Esse conjunto de colunas pode ser gerado de uma chave primária de tabela base, uma restrição UNIQUE ou um índice exclusivo.This set of columns may be generated from a base table primary key, a unique constraint, or a unique index.false: A coluna não é necessária para identificar exclusivamente a linha.false: The column is not required to uniquely identify the row. |
| IsAutoIncrementIsAutoIncrement | true se a coluna atribuir valores a novas linhas em incrementos fixos; caso contrário false .true if the column assigns values to new rows in fixed increments; otherwise false. O padrão para essa coluna é false .The default for this column is false. |
| BaseSchemaNameBaseSchemaName | O nome do esquema na fonte de dados que contém a coluna.The name of the schema in the data source that contains the column. NULL se o nome do catálogo base não puder ser determinado.NULL if the base catalog name cannot be determined. O padrão para esta coluna é um valor nulo.The default for this column is a null value. |
| BaseCatalogNameBaseCatalogName | O nome do catálogo no repositório de dados que contém a coluna.The name of the catalog in the data store that contains the column. NULL se o nome do catálogo base não puder ser determinado.NULL if the base catalog name cannot be determined. O padrão para esta coluna é um valor nulo.The default for this column is a null value. |
| BaseTableNameBaseTableName | O nome da tabela ou exibição no repositório de dados que contém a coluna.The name of the table or view in the data store that contains the column. Um valor nulo se o nome da tabela de base não pode ser determinado.A null value if the base table name cannot be determined. O padrão desta coluna é um valor nulo.The default of this column is a null value. |
| BaseColumnNameBaseColumnName | O nome da coluna no repositório de dados.The name of the column in the data store. Isso pode ser diferente do nome da coluna retornado na coluna ColumnName se um alias tiver sido usado.This might be different from the column name returned in the ColumnName column if an alias was used. Um valor nulo se o nome da coluna base não puder ser determinado ou se a coluna do conjunto de linhas for derivada, mas não for idêntica a uma coluna no repositório de dados.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. O padrão para esta coluna é um valor nulo.The default for this column is a null value. |
Uma linha é retornada para cada coluna no conjunto de resultados.A row is returned for every column in the results set.
O .NET Framework Provedor de Dados para ODBC pressupõe que as informações de metadados estão disponíveis em um driver ODBC depois que uma das funções SQLPrepare, SQLExecute ou SQLExecuteDirect é chamada.The .NET Framework Data Provider for ODBC assumes that metadata information is available from an ODBC driver after one of SQLPrepare, SQLExecute, or SQLExecuteDirect functions are called. Para que o comportamento do comando "SchemaOnly" funcione corretamente, o SQLPrepare deve retornar as informações de metadados necessárias.For "SchemaOnly" command behavior to work correctly, SQLPrepare must return the required metadata information. Nem todos os drivers ODBC dão suporte a essa função ou retornam informações de metadados.Not all ODBC drivers support this function or return metadata information. Nesses casos, parte ou todas as informações no Esquematable estarão ausentes.In these cases, part or all of the information in the SchemaTable will be missing. Depois de chamar SQLPrepare, o provedor de dados chama a função ODBC SQLColAttribute para localizar as informações de metadados relacionadas a cada coluna nos resultados da consulta (por exemplo, IsLong, IsUnique, AllowDBNull, BaseTableName, BaseColumnName).After calling SQLPrepare, The data provider calls the ODBC SQLColAttribute function to find the metadata information related to each column in the query results (for example, IsLong, IsUnique, AllowDBNull, BaseTableName, BaseColumnName). Se o driver subjacente não retornar algumas dessas informações, os valores correspondentes no Esquematable não serão definidos corretamente.If the underlying driver does not return some of this information, the corresponding values in the SchemaTable will not be set correctly.
O .NET Framework Provedor de Dados para ODBC também chama SQLPrimaryKeys para recuperar as informações de chave para cada tabela.The .NET Framework Data Provider for ODBC also calls SQLPrimaryKeys to retrieve the key information for every table. Se o driver ODBC subjacente não oferecer suporte a essa função, o provedor de dados chamará SQLStatistics e escolherá um dos índices exclusivos como a chave primária para a tabela.If the underlying ODBC driver does not support this function, the data provider calls SQLStatistics and chooses one of the unique indexes as the primary key for the table. Isso nem sempre pode fornecer os resultados desejados.This may not always give the results that you want.
OdbcCommandBuilder precisa da identificação correta das chaves primárias da tabela para funcionar corretamente.OdbcCommandBuilder needs the correct identification of the primary keys of the table in order to work correctly. Se o BaseTableName não for retornado para cada coluna nos resultados da consulta, o .NET Framework Provedor de Dados para ODBC tentará analisar a instrução SQL para localizar os nomes de tabela envolvidos na consulta.If the BaseTableName is not returned for every column in the query results, the .NET Framework Data Provider for ODBC tries to parse the SQL statement to find the table names involved in the query. Isso funciona com as instruções UPDATE, INSERT, DELETE e SELECT simples, mas não com procedimentos armazenados ou instruções SELECT com base em junções.This works with UPDATE, INSERT, DELETE and simple SELECT statements, but not with stored procedures or SELECT statements based on joins. Se algumas ou todas as informações de esquema estiverem faltando nesta tabela, o OdbcCommandBuilder não funcionará corretamente, pois ela tem informações de esquema insuficientes para gerar automaticamente as instruções INSERT, Update ou DELETE corretas.If some or all the schema information is missing from this table, the OdbcCommandBuilder will not work correctly, because it has insufficient schema information to automatically generate the correct INSERT, UPDATE, or DELETE statements.
Para garantir que as colunas de metadados retornem as informações corretas, você deve chamar ExecuteReader com o parâmetro de comportamento definido como KeyInfo.To make sure that metadata columns return the correct information, you must call ExecuteReader with the behavior parameter set to KeyInfo. Caso contrário, algumas das colunas na tabela de esquema podem retornar dados padrão, nulos ou incorretos.Otherwise, some of the columns in the schema table may return default, null, or incorrect data.
Quando você usa ODBC.NET para Oracle por meio do driver ODBC, as colunas de chave com alias não são reconhecidas como chaves.When you use ODBC.NET to Oracle via the ODBC driver, aliased key columns are not recognized as keys. Isso afeta as colunas IsKey e IsUnique na tabela de esquema do OdbcDataReader.This affects the IsKey and IsUnique columns in the schema table of the OdbcDataReader. Ele também afeta a capacidade do OdbcCommandBuilder de gerar a lógica de atualização.It also affects the OdbcCommandBuilder's ability to generate updating logic. Considere não usar um alias para uma coluna de chave primária.Consider not using an alias for a primary key column.
Observação
O driver ODBC do Microsoft Jet sempre retorna colunas de índice exclusivo e de chave primária como anuláveis, independentemente de serem anuláveis ou não.The Microsoft Jet ODBC driver always returns unique index and primary key columns as nullable regardless of whether they are nullable or not. O driver também não retorna informações de chave primária; Ele retorna apenas uma lista de índices exclusivos e suas colunas, incluindo colunas de chave primária, sem diferenciar entre eles.The driver also does not return primary key information; it only returns a list of unique indexes and their columns, including primary key columns, without differentiating among them.