Esempio n. 1
0
        public void Create(EJ.Databases database)
        {
            Pomelo.Data.MySql.MySqlConnectionStringBuilder conStrBuilder = new Pomelo.Data.MySql.MySqlConnectionStringBuilder(database.conStr);
            database.Name          = conStrBuilder.Database;
            conStrBuilder.Database = null;

            IDatabaseService db;

            try
            {
                db = EntityDB.DBContext.CreateDatabaseService(conStrBuilder.ToString(), EntityDB.DatabaseType.MySql);
                db.ExecSqlString("create database if not exists `" + database.Name.ToLower() + "` CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'");
            }
            catch
            {
            }


            //创建必须表
            db = EntityDB.DBContext.CreateDatabaseService(database.conStr, EntityDB.DatabaseType.MySql);
            db.DBContext.BeginTransaction();
            try
            {
                CreateEasyJobTable(db);
                db.DBContext.CommitTransaction();
            }
            catch (Exception ex)
            {
                db.DBContext.RollbackTransaction();
                throw ex;
            }
        }
Esempio n. 2
0
        public void Drop(EJ.Databases database)
        {
            Pomelo.Data.MySql.MySqlConnectionStringBuilder conStrBuilder = new Pomelo.Data.MySql.MySqlConnectionStringBuilder(database.conStr);
            database.Name          = conStrBuilder.Database;
            conStrBuilder.Database = null;

            var db = EntityDB.DBContext.CreateDatabaseService(conStrBuilder.ToString(), EntityDB.DatabaseType.MySql);

            db.ExecSqlString("drop database if exists `" + database.Name.ToLower() + "`");
            db.DBContext.Dispose();
        }
Esempio n. 3
0
        public void ConnectionString_Check()
        {
            System.Data.SqlClient.SqlConnectionStringBuilder conStrBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder("server=ETHAN-20171016H;uid=sa;pwd=123;Database=TestDB");
            conStrBuilder.InitialCatalog = "master";
            var constr = conStrBuilder.ToString();

            //Server=;Port=5432;UserId=;Password=;Database=;
            Npgsql.NpgsqlConnectionStringBuilder conStrBuilder2 = new Npgsql.NpgsqlConnectionStringBuilder("Server=localhost;Port=5432;UserId=sa;Password=1;Database=testDB;");
            conStrBuilder2.Database = null;
            constr = conStrBuilder2.ToString();

            Pomelo.Data.MySql.MySqlConnectionStringBuilder conStrBuilder3 = new Pomelo.Data.MySql.MySqlConnectionStringBuilder("server=locahost;User Id=sa;password=12;Database=testDB");
            conStrBuilder3.Database = null;
            constr = conStrBuilder3.ToString();

            //server=;User Id=;password=;Database=
        }