public List <string> GetViewNames() { string sql1 = string.Format(@" SELECT TABLE_NAME, TABLE_SCHEMA, 0 AS IsSystemObject FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{0}' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME" , DatabaseName); List <string> viewNames = 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) { viewNames.Add(sqlDataReader.GetString(ordTableName) + "|" + sqlDataReader.GetString(ordTableSchema)); } } } finally { if (sqlDataReader != null) // && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } } return(viewNames); }
public List <string> GetViewNames() { string where = string.IsNullOrEmpty(SchemaFilterCSV) ? "" : string.Format("WHERE OWNER IN ({0})", SchemaFilterCSV); string sql1 = string.Format(@" SELECT VIEW_NAME, OWNER AS VIEW_SCHEMA, 0 AS IsSystemObject FROM All_Views {0} ORDER BY VIEW_NAME " , where); List <string> viewNames = new List <string>(); UniDataReader sqlDataReader = null; try { sqlDataReader = RunQuerySQL(sql1); // Exclude system tables int isSysObjectColumnOrdinal = sqlDataReader.GetOrdinal("IsSystemObject"); int ordTableName = sqlDataReader.GetOrdinal("VIEW_NAME"); int ordTableSchema = sqlDataReader.GetOrdinal("VIEW_SCHEMA"); while (sqlDataReader.Read()) { bool isSystemObject = sqlDataReader.IsDBNull(isSysObjectColumnOrdinal) ? false : (bool)sqlDataReader.GetBoolean(isSysObjectColumnOrdinal); if (!isSystemObject) { viewNames.Add(sqlDataReader.GetString(ordTableName) + "|" + sqlDataReader.GetString(ordTableSchema)); } } } finally { if (sqlDataReader != null) // && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } } return(viewNames); }