Example #1
0
        private void btnTestDbConnection_Click(object sender, EventArgs e)
        {
            AbstractDatabase tmpDb;

            tmpDb = null;
            if (rdoJson.Checked)
            {
                tmpDb = new JsonDatabase();
            }
            if (rdoMSSQL.Checked)
            {
                tmpDb = new SqlServerDatabase();
            }
            if (rdoMySQL.Checked)
            {
                tmpDb = new MySqlDatabase();
            }
            if (rdoSQLite.Checked)
            {
                tmpDb = new SQLiteDatabase();
            }
            if (rdoXML.Checked)
            {
                tmpDb = new XMLDatabase();
            }

            tmpDb.ConnectionString = BuildConnectionString().EncryptTextToBase64String();
            if (tmpDb.TestConnection())
            {
                MessageBox.Show("Success!");
            }
        }
Example #2
0
        internal static AbstractDatabase GetDatabase()
        {
            AbstractDatabase db = null;

            switch (settings.dbType)
            {
            case 0:
                db = new JsonDatabase();
                db.ConnectionString = settings.dbServer;
                break;

            case 1:
                db = new SqlServerDatabase();
                db.ConnectionString = settings.dbConnStr;
                break;

            case 2:
                db = new MySqlDatabase();
                db.ConnectionString = settings.dbConnStr;
                break;

            case 3:
                db = new SQLiteDatabase();
                db.ConnectionString = settings.dbConnStr;
                break;

            case 4:
                db = new XMLDatabase();
                db.ConnectionString = settings.dbServer;
                break;
            }
            db.CreateTable();

            return(db);
        }