Exemple #1
0
        public virtual DataBase CreateTable()
        {
            dt = conn.getTableStructure();
            db.DataBaseName1 = DBName;
            string tempTable = "a b c";
            string kieuDuLieu;
            Table  tb = null;

            foreach (DataRow item in dt.Rows)
            {
                kieuDuLieu = item["DATA_TYPE"].ToString().ToLower();

                if (tempTable != item["TABLE_NAME"].ToString())
                {
                    if (tempTable != item["TABLE_NAME"].ToString() && tb != null)
                    {
                        db.ListTable.Add(tb);
                    }
                    //chuẩn hóa tên bảng nếu chứa khoảng trắng
                    tempTable = item["TABLE_NAME"].ToString();

                    tb            = new Table();
                    tb.TableName1 = standardizing(tempTable);
                }


                tb.ListColumns.Add(new Column(standardizing(item["COLUMN_NAME"].ToString()),
                                              getTypeData(kieuDuLieu, item["CHARACTER_MAXIMUM_LENGTH"].ToString(), item["NUMERIC_PRECISION"].ToString(), item["NUMERIC_SCALE"].ToString()),
                                              checkNull(item["IS_NULLABLE"].ToString())));
            }
            db.ListTable.Add(tb);
            return(db);
        }