Beispiel #1
0
        /// <summary>
        /// 填充表数据Records
        /// </summary>
        /// <param name="sql">查询语句</param>
        protected override void FillRecords(string sql)
        {
            SQLDBOperator opt = new SQLDBOperator(this.ConnectionString);

            object[][] dataRows = opt.GetDataRows(sql);

            foreach (object[] dataRow in dataRows)
            {
                SQLDBRecord record = new SQLDBRecord(this.TableName, this.IdentifierName, this.ConnectionString, Columns);
                for (int i = 0; i < dataRow.Length; i++)
                {
                    record.Fields[i].Value = dataRow[i];
                }
                record.State = Enums.DBRecordState.Saved;
                this.Records.Add(record);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 初始化全部列
        /// </summary>
        protected override void InitializeColumn()
        {
            string sql = @"SELECT sys.syscolumns.name, sys.systypes.name AS type
                            FROM sys.syscolumns INNER JOIN
                            sys.sysobjects ON sys.syscolumns.id = sys.sysobjects.id AND sys.sysobjects.name = @0 AND 
                            sys.sysobjects.xtype = 'U' INNER JOIN
                            sys.systypes ON sys.systypes.xusertype = sys.syscolumns.xusertype";

            SQLDBOperator dbOperator = new SQLDBOperator(this.ConnectionString);

            object[][] rows = dbOperator.GetDataRows(sql, this.TableName);

            for (int i = 0; i < rows.Length; i++)
            {
                Enums.DataType type   = Enums.GetColumnDataTypeByNameString(rows[i][1].ToString());
                DBColumn       column = new DBColumn(rows[i][0].ToString(), type);
                this.Columns.Add(column);
            }
        }