internal void GetSqlTableInfo() { string cmdText = "exec sp_tables"; SqlCommand selectCommand = new SqlCommand(cmdText, this.SqlConn); DataSet dataSet = new DataSet(); new SqlDataAdapter(selectCommand).Fill(dataSet, "Tables"); this.m_AllTables = new SqlTableInfoArray(); this.m_UserTables = new SqlTableInfoArray(); this.m_SystemTables = new SqlTableInfoArray(); this.m_Views = new SqlTableInfoArray(); foreach (DataRow row in dataSet.Tables[0].Rows) { SqlTableInfo sqlTableInfo = new SqlTableInfo(this, row); this.m_AllTables.Add(sqlTableInfo); switch (sqlTableInfo.Type) { case TableType.Table: { this.m_UserTables.Add(sqlTableInfo); continue; } case TableType.SystemTable: { this.m_SystemTables.Add(sqlTableInfo); continue; } case TableType.View: { this.m_Views.Add(sqlTableInfo); continue; } } } }
internal void Add(SqlTableInfo SqlTableInfo) { this.m_Tables.Add(SqlTableInfo); }
// Methods internal SqlFieldInfo(SqlTableInfo table, DataRow row) { this.Table = table; this.Name = (string)row["COLUMN_NAME"]; this.Type = (string)row["TYPE_NAME"]; this.Precision = (int)row["PRECISION"]; this.Length = (int)row["LENGTH"]; object obj2 = row["SCALE"]; this.Scale = (obj2 is DBNull) ? ((short)(-1)) : ((short)obj2); this.AllowsNull = ((short)row["NULLABLE"]) != 0; this.Position = (int)row["ORDINAL_POSITION"]; object obj3 = row["COLUMN_DEF"]; this.DefaultValue = (obj3 is DBNull) ? string.Empty : ((string)obj3); this.IsPKField = (bool)row["PKEY"]; this.IsAutoCalculated = (bool)row["AUTO"]; this.IsCalculated = (bool)row["CALCULATED"]; this.PKPosition = (short)row["PKPOSITION"]; }