private static SqlServerColumn[] GetColumnsOfTable_2005(string table) { const string strSql = "select c.name as ColumnName, ty.name as ColumnType, c.max_length as ColumnSize\r\n from sys.columns as c\r\n inner join sys.tables as t on t.object_id=c.object_id\r\n inner join sys.types as ty on ty.system_type_id = c.system_type_id\r\nwhere ty.system_type_id=ty.user_type_id and t.name=@TheTable"; IDataReader dataReader = (IDataReader)null; try { Database database2 = DatabaseFactory.CreateDatabase(); DbCommand sqlStringCommand = database2.GetSqlStringCommand(strSql); database2.AddInParameter(sqlStringCommand, "@TheTable", DbType.AnsiString, (object)table); dataReader = database2.ExecuteReader(sqlStringCommand); List <SqlServerColumn> list = new List <SqlServerColumn>(32); while (dataReader.Read()) { SqlServerColumn sqlServerColumn = new SqlServerColumn() { ColumnName = dataReader.GetString(0), ColumnType = dataReader.GetString(1), ColumnSize = int.Parse(dataReader.GetValue(2).ToString()) }; list.Add(sqlServerColumn); } return(list.Count == 0 ? (SqlServerColumn[])null : list.ToArray()); } catch (Exception ex) { throw ex; } finally { if (dataReader != null) { dataReader.Close(); } } }
private static SqlServerColumn[] GetColumnsOfTable_2005(string table) { const string strSql = "select c.name as ColumnName, ty.name as ColumnType, c.max_length as ColumnSize\r\n from sys.columns as c\r\n inner join sys.tables as t on t.object_id=c.object_id\r\n inner join sys.types as ty on ty.system_type_id = c.system_type_id\r\nwhere ty.system_type_id=ty.user_type_id and t.name=@TheTable"; IDataReader dataReader = (IDataReader) null; try { Database database2 = DatabaseFactory.CreateDatabase(); DbCommand sqlStringCommand = database2.GetSqlStringCommand(strSql); database2.AddInParameter(sqlStringCommand, "@TheTable", DbType.AnsiString, (object) table); dataReader = database2.ExecuteReader(sqlStringCommand); List<SqlServerColumn> list = new List<SqlServerColumn>(32); while (dataReader.Read()) { SqlServerColumn sqlServerColumn = new SqlServerColumn() { ColumnName = dataReader.GetString(0), ColumnType = dataReader.GetString(1), ColumnSize = int.Parse(dataReader.GetValue(2).ToString()) }; list.Add(sqlServerColumn); } return list.Count == 0 ? (SqlServerColumn[]) null : list.ToArray(); } catch (Exception ex) { throw ex; } finally { if (dataReader != null) dataReader.Close(); } }