public override DatabaseSchema CreateDatabaseSchema(string name)
        {
            SqlServerDatabaseSchema schema = new SqlServerDatabaseSchema(this);

            schema.Name = name;
            return(schema);
        }
Esempio n. 2
0
        public void SetDatabaseOptions(SqlServerDatabaseSchema schema)
        {
            TreeIter iter;

            if (comboCollations.GetActiveIter(out iter))
            {
                schema.Collation = (SqlServerCollationSchema)storeCollations.GetValue(iter, 1);
            }
            SizeType size;

            size           = (SizeType)Enum.Parse(typeof(SizeType), comboSize.ActiveText);
            schema.Size    = new FileSize(Convert.ToInt32(spinSize.Value), size);
            size           = (SizeType)Enum.Parse(typeof(SizeType), comboMaxSize.ActiveText);
            schema.MaxSize = new FileSize(Convert.ToInt32(spinMaxSize.Value), size);
            if (comboFilegrowth.ActiveText == "%")
            {
                size = SizeType.PERCENTAGE;
            }
            else
            {
                size = (SizeType)Enum.Parse(typeof(SizeType), comboFilegrowth.ActiveText);
            }
            schema.FileGrowth  = new FileSize(Convert.ToInt32(spinFilegrowth.Value), size);
            schema.LogicalName = entryName.Text;
            schema.FileName    = entryFilename.Text;
        }
        //http://msdn2.microsoft.com/en-us/library/aa258257(SQL.80).aspx
        public override void CreateDatabase(DatabaseSchema database)
        {
            SqlServerDatabaseSchema schema = (SqlServerDatabaseSchema)database;
            StringBuilder           db     = new StringBuilder("CREATE DATABASE ");
            string newLine = Environment.NewLine;

            db.Append(schema.Name);
            if (schema.FileName != string.Empty && schema.Name != string.Empty)
            {
                db.AppendLine();
                db.Append("ON ");
                db.AppendFormat("{0}(NAME = {1},", newLine, schema.LogicalName);
                db.AppendFormat("{0}FILENAME = '{1}'", newLine, schema.FileName);
                if (schema.Size.Size > 0)
                {
                    db.AppendFormat(",{0}SIZE = {1}{2}", newLine, schema.Size.Size.ToString(), schema.Size.Type);
                }
                if (schema.MaxSize.Size > 0)
                {
                    db.AppendFormat(",{0}MAXSIZE = {1}{2}", newLine, schema.MaxSize.Size.ToString(), schema.MaxSize.Type);
                }
                if (schema.FileGrowth.Size > 0)
                {
                    db.AppendFormat(",{0}FILEGROWTH = {1}{2}", newLine, schema.FileGrowth.Size.ToString(), schema.FileGrowth.Type == SizeType.PERCENTAGE ? "%" : schema.FileGrowth.Type.ToString());
                }
                db.Append(")");
            }
            if (schema.Collation != null)
            {
                db.AppendFormat("{0}COLLATE {1}{0}", newLine, schema.Collation.Name);
            }

            using (IPooledDbConnection conn = connectionPool.Request()) {
                using (IDbCommand command = conn.CreateCommand(db.ToString()))
                    try {
                        command.ExecuteNonQuery();
                    } catch (Exception e) {
                        QueryService.RaiseException(e);
                    }finally {
                    conn.Release();
                }
            }
        }
		public void SetDatabaseOptions (SqlServerDatabaseSchema schema)
		{
			TreeIter iter;
			if (comboCollations.GetActiveIter (out iter))
				schema.Collation = (SqlServerCollationSchema)storeCollations.GetValue (iter, 1);
			SizeType size;
			
			size = (SizeType)Enum.Parse (typeof(SizeType), comboSize.ActiveText);
			schema.Size = new FileSize (Convert.ToInt32(spinSize.Value), size);
			size = (SizeType)Enum.Parse (typeof(SizeType), comboMaxSize.ActiveText);
			schema.MaxSize = new FileSize (Convert.ToInt32(spinMaxSize.Value), size);
			if (comboFilegrowth.ActiveText == "%")
				size = SizeType.PERCENTAGE; 
			else
				size = (SizeType)Enum.Parse (typeof(SizeType), comboFilegrowth.ActiveText);
			schema.FileGrowth = new FileSize (Convert.ToInt32(spinFilegrowth.Value), size);
			schema.LogicalName = entryName.Text;
			schema.FileName = entryFilename.Text;
		}
		
		public override DatabaseSchema CreateDatabaseSchema (string name)
		{
			SqlServerDatabaseSchema schema = new SqlServerDatabaseSchema (this);
			schema.Name = name;
			return schema;