public List <string> GetTableNames() { string where = string.IsNullOrEmpty(SchemaFilterCSV) ? "WHERE NESTED <> 'YES'" : string.Format("WHERE OWNER IN ({0}) AND NESTED <> 'YES'", SchemaFilterCSV); string sql1 = string.Format(@" SELECT TABLE_NAME, OWNER AS TABLE_SCHEMA, 0 AS IsSystemObject FROM All_Tables {0} ORDER BY TABLE_NAME " , where); List <string> tableNames = new List <string>(); UniDataReader sqlDataReader = null; try { sqlDataReader = RunQuerySQL(sql1); // Exclude system tables int isSysObjectColumnOrdinal = sqlDataReader.GetOrdinal("IsSystemObject"); int ordTableName = sqlDataReader.GetOrdinal("TABLE_NAME"); int ordTableSchema = sqlDataReader.GetOrdinal("TABLE_SCHEMA"); while (sqlDataReader.Read()) { bool isSystemObject = sqlDataReader.IsDBNull(isSysObjectColumnOrdinal) ? false : (bool)sqlDataReader.GetBoolean(isSysObjectColumnOrdinal); if (!isSystemObject) { tableNames.Add(sqlDataReader.GetString(ordTableName) + "|" + sqlDataReader.GetString(ordTableSchema)); } } } finally { if (sqlDataReader != null) // && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } } return(tableNames); }
public List <string> GetTableNames() { string sql1 = @" SELECT TABLE_NAME, TABLE_SCHEMA, 0 AS IsSystemObject FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME " ; List <string> tableNames = new List <string>(); UniDataReader sqlDataReader = null; try { sqlDataReader = RunQuerySQL(sql1); // Exclude system tables int isSysObjectColumnOrdinal = sqlDataReader.GetOrdinal("IsSystemObject"); int ordTableName = sqlDataReader.GetOrdinal("TABLE_NAME"); int ordTableSchema = sqlDataReader.GetOrdinal("TABLE_SCHEMA"); while (sqlDataReader.Read()) { bool isSystemObject = sqlDataReader.IsDBNull(isSysObjectColumnOrdinal) ? false : (bool)sqlDataReader.GetBoolean(isSysObjectColumnOrdinal); if (!isSystemObject) { tableNames.Add(sqlDataReader.GetString(ordTableName) + "|" + sqlDataReader.GetString(ordTableSchema)); } } } finally { if (sqlDataReader != null) // && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } } return(tableNames); }