예제 #1
0
 public PDAField(DataRows row)
 {
     Name = row.FieldByName("COLUMN_NAME");
     Nullable = row.FieldByName("IS_NULLABLE").ToUpper() == "YES";
     DataType = row.FieldByName("DATA_TYPE");
     SLen = row.FieldByNameDef("CHARACTER_MAXIMUM_LENGTH", "");
     PLen = row.FieldByNameDef("NUMERIC_PRECISION", "");
     DLen = row.FieldByNameDef("NUMERIC_SCALE", "");
     if (SLen != "")
         FullDataType = DataType + "(" + SLen + ")";
     else
     {
         if (PLen != "")
         {
             if (DLen != "")
                 FullDataType = DataType + "(" + PLen + ", " + DLen + ")";
             else
                 FullDataType = DataType + "(" + PLen + ")";
         }
         else
             FullDataType = DataType;
     }
     if (DataType.ToLower() == "datetime") FullDataType = DataType;
     List<DataRows> lst;
     q.Select(
         "SELECT a.Column_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE a, INFORMATION_SCHEMA.TABLE_CONSTRAINTS b WHERE (a.CONSTRAINT_NAME = b.CONSTRAINT_NAME) AND (a.TABLE_NAME = '"+ row.FieldByName("TABLE_NAME")+"') AND COLUMN_NAME='"+Name+"' ORDER BY a.TABLE_NAME");
     lst = q.GetRows();
     if(lst.Count>0)
     {
         IsPK = true;
     }
 }
예제 #2
0
 public static void Add(DataRows row)
 {
     foreach (PDATable table in tables)
     {
         if(table.Name == row.FieldByName("TABLE_NAME"))
         {
             table.AddField(row);
             return;
         }
     }
     PDATable newtable = new PDATable();
     newtable.Name = row.FieldByName("TABLE_NAME");
     tables.Add(newtable);
     newtable.AddField(row);
 }
예제 #3
0
        public static void Add(DataRows row)
        {
            foreach (PDATable table in tables)
            {
                if (table.Name == row.FieldByName("TABLE_NAME"))
                {
                    table.AddField(row);
                    return;
                }
            }
            PDATable newtable = new PDATable();

            newtable.Name = row.FieldByName("TABLE_NAME");
            tables.Add(newtable);
            newtable.AddField(row);
        }
예제 #4
0
        public PDAField(DataRows row)
        {
            Name     = row.FieldByName("COLUMN_NAME");
            Nullable = row.FieldByName("IS_NULLABLE").ToUpper() == "YES";
            DataType = row.FieldByName("DATA_TYPE");
            SLen     = row.FieldByNameDef("CHARACTER_MAXIMUM_LENGTH", "");
            PLen     = row.FieldByNameDef("NUMERIC_PRECISION", "");
            DLen     = row.FieldByNameDef("NUMERIC_SCALE", "");
            if (SLen != "")
            {
                FullDataType = DataType + "(" + SLen + ")";
            }
            else
            {
                if (PLen != "")
                {
                    if (DLen != "")
                    {
                        FullDataType = DataType + "(" + PLen + ", " + DLen + ")";
                    }
                    else
                    {
                        FullDataType = DataType + "(" + PLen + ")";
                    }
                }
                else
                {
                    FullDataType = DataType;
                }
            }
            if (DataType.ToLower() == "datetime")
            {
                FullDataType = DataType;
            }
            List <DataRows> lst;

            q.Select(
                "SELECT a.Column_name FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE a, INFORMATION_SCHEMA.TABLE_CONSTRAINTS b WHERE (a.CONSTRAINT_NAME = b.CONSTRAINT_NAME) AND (a.TABLE_NAME = '" + row.FieldByName("TABLE_NAME") + "') AND COLUMN_NAME='" + Name + "' ORDER BY a.TABLE_NAME");
            lst = q.GetRows();
            if (lst.Count > 0)
            {
                IsPK = true;
            }
        }
예제 #5
0
        private void AddField(DataRows row)
        {
            foreach (PDAField field in fields)
            {
                if (field.Name == row.FieldByName("COLUMN_NAME"))
                {
                    throw new Exception("Двойное поле");
                }
            }
            PDAField newfield = new PDAField(row);

            fields.Add(newfield);
        }
예제 #6
0
 private void AddField(DataRows row)
 {
     foreach (PDAField field in fields)
     {
         if(field.Name == row.FieldByName("COLUMN_NAME"))
             throw new Exception("Двойное поле");
     }
     PDAField newfield = new PDAField(row);
     fields.Add(newfield);
 }