コード例 #1
0
        public static void SetConnection()
        {
            string _connectionString;

            _connectionString = string.Format("SERVER={0};PORT={1};DATABASE={2};UID={3};PASSWORD={4};CHARSET=utf8;", Server, Port, Database, UserName, Password);
            connection        = new MySqlConnection(_connectionString);
            try
            {
                connection.Open();
            }
            catch (MySqlException e)
            {
                switch (e.Number)
                {
                case 0:
                    Log.Out("[ServerTools] MySqlException in MySqlDatabase.SetConnection: Cannot connect to server.");
                    break;

                case 1045:
                    Log.Out("[ServerTools] MySqlException in MySqlDatabase.SetConnection: Invalid username/password, please try again.");
                    break;
                }
                return;
            }
            connection.Close();
            CreateTables();
            // can remove the below a few months after release
            string _binpath = string.Format("{0}/ServerTools.bin", GameUtils.GetSaveGameDir());

            if (File.Exists(_binpath))
            {
                UpdateToSqlFromBin.Exec();
            }
            //----------------------------------------------------------------------------------------
        }
コード例 #2
0
        public static void SetConnection()
        {
            string _dbConnection;
            string _filepath = string.Format("{0}/ServerTools.db", GameUtils.GetSaveGameDir());

            if (File.Exists(_filepath))
            {
                _dbConnection = string.Format("Data Source={0};Version=3;New=False;Compress=True;", _filepath);
            }
            else
            {
                _dbConnection = string.Format("Data Source={0};Version=3;New=True;Compress=True;", _filepath);
            }
            connection = new SQLiteConnection(_dbConnection);
            CreateTables();
            // can remove the below a few months after release
            string _binpath = string.Format("{0}/ServerTools.bin", GameUtils.GetSaveGameDir());

            if (File.Exists(_binpath))
            {
                UpdateToSqlFromBin.Exec();
            }
            //----------------------------------------------------------------------------------------
        }