private static DataTable GetIndexCollection(string?[]?restrictions, OdbcConnection connection) { OdbcCommand? command = null; OdbcDataReader?dataReader = null; DataTable? resultTable = null; const int nativeRestrictionsCount = 5; const int indexRestrictionsCount = 4; const int indexOfTableName = 2; const int indexOfIndexName = 3; try { command = GetCommand(connection); object[] allRestrictions = new object[nativeRestrictionsCount]; FillOutRestrictions(indexRestrictionsCount, restrictions, allRestrictions, OdbcMetaDataCollectionNames.Indexes); if (allRestrictions[indexOfTableName] == null) { throw ODBC.GetSchemaRestrictionRequired(); } allRestrictions[3] = (short)ODBC32.SQL_INDEX.ALL; allRestrictions[4] = (short)ODBC32.SQL_STATISTICS_RESERVED.ENSURE; dataReader = command.ExecuteReaderFromSQLMethod(allRestrictions, ODBC32.SQL_API.SQLSTATISTICS); string?indexName = null; if (restrictions != null) { if (restrictions.Length >= indexOfIndexName + 1) { indexName = restrictions[indexOfIndexName]; } } resultTable = DataTableFromDataReaderIndex(dataReader, OdbcMetaDataCollectionNames.Indexes, indexName); } finally { dataReader?.Dispose();; command?.Dispose();; } return(resultTable); }
private DataTable GetIndexCollection(string[] restrictions, OdbcConnection connection) { OdbcDataReader reader = null; OdbcCommand command = null; DataTable table = null; try { command = this.GetCommand(connection); object[] allRestrictions = new object[5]; this.FillOutRestrictions(4, restrictions, allRestrictions, OdbcMetaDataCollectionNames.Indexes); if (allRestrictions[2] == null) { throw ODBC.GetSchemaRestrictionRequired(); } allRestrictions[3] = (short)1; allRestrictions[4] = (short)1; reader = command.ExecuteReaderFromSQLMethod(allRestrictions, ODBC32.SQL_API.SQLSTATISTICS); string restrictionIndexName = null; if ((restrictions != null) && (restrictions.Length >= 4)) { restrictionIndexName = restrictions[3]; } table = this.DataTableFromDataReaderIndex(reader, OdbcMetaDataCollectionNames.Indexes, restrictionIndexName); } finally { if (reader != null) { reader.Dispose(); } if (command != null) { command.Dispose(); } } return(table); }