Exemple #1
0
        protected virtual void FillPrimaryKey(DBTable table)
        {
            OleDbDataReader rdPK = OleDbHelper.ExecuteReader(this.OleDbConnStr, string.Format(this.Format_GET_ALL_PrimaryKeys, table.TableName));

            while (rdPK.Read())
            {
                string columnName = rdPK["COLUMN_NAME"].ToString();
                DBColumn column = table.Columns.Where(row => row.ColumnName == columnName).FirstOrDefault();
                if (column != null)
                {
                    table.SetPrimaryKey(column, false, 0, 0, 1);
                }
            }
            rdPK.Close();
            rdPK.Dispose();
        }
Exemple #2
0
        protected override void FillPrimaryKey(DBTable table)
        {
            OleDbDataReader rdPK = OleDbHelper.ExecuteReader(this.OleDbConnStr, string.Format(this.Format_GET_ALL_PrimaryKeys, table.TableName));
            //List<DBColumn> fields = new List<DBColumn>();
            OleDbDataReader rdIdentity = OleDbHelper.ExecuteReader(this.OleDbConnStr, string.Format(format_GetAllIdentityColumn, table.TableName));
            string identityColumnName = "";
            if (rdIdentity.HasRows)
            {
                identityColumnName = rdIdentity["Iden_Column_name"].ToString();
            }
            rdIdentity.Close();
            rdIdentity.Dispose();
            while (rdPK.Read())
            {
                string columnName = rdPK["COLUMN_NAME"].ToString();
                DBColumn column = table.Columns.Where(row => row.ColumnName == columnName).FirstOrDefault();
                if (column != null)
                {
                    if (columnName == identityColumnName)
                    {
                        table.SetPrimaryKey(
                            column
                            , true
                            , int.Parse(rdIdentity["seed_value"].ToString())
                            , int.Parse(rdIdentity["curr_value"].ToString())
                            , int.Parse(rdIdentity["incr_value"].ToString())
                            );
                    }
                    else
                    {
                        table.SetPrimaryKey(column, false, 0, 0, 1);
                    }

                }
            }
            rdPK.Close();
            rdPK.Dispose();
        }