第1行的“is_working”列截断了数据

时间:2016-10-10 13:57:18

标签: c# mysql

我有一个游戏模拟器,当用户注销服务器时,我使用以下查询保存他们的统计数据。

public void Dispose()
        {
            try
            {
                Console.WriteLine((this.isWorking == true ? 1 : 0));
                using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
                {
                    dbClient.SetQuery("UPDATE `roleplay_statistics` SET `current_health` = @currentHealth, `current_hunger` = @currentHunger, `current_energy` = @currentEnergy, `current_hygiene` = @currentHygiene, `bank_balance` = @bankBalance, `government_group` = @governmentGroup, `kill_count` = @killCount, `death_count` = @deathCount, `hits_thrown` = @hitsThrown, `hits_received` = @hitsReceived, `total_cash_earned` = @totalCashEarned, `current_fitness_level` = @fitnessLevel, `fitness_xp` = @fitnessXp, `current_strength_level` = @strengthLevel, `strength_xp` = @strengthXp, `education_grade_overall` = @overallGrade, `skill_level_overall` = @overallSkillLevel, `blood_type` = @bloodType, `health_service_number` = @healthServiceNumber, `national_insurance_number` = @nationalInsuranceNumber, `business_id` = @businessId, `business_position` = @businessPosition, `government_id` = @govId, `cooking_level` = @cookingLevel, `cooking_xp` = @cookingXp, `fishing_level` = @fishingLevel, `fishing_xp` = @fishingXp, `farming_level` = @farmingLevel, `farming_xp` = @farmingXp, `mining_level` = @miningLevel, `mining_xp` = @miningXp, `woodcutting_level` = @woodcuttingLevel, `woodcutting_xp` = @woodcuttingXp, `english_grade` = @englishGrade, `english_xp` = @englishXp, `science_grade` = @scienceGrade, `science_xp` = @scienceXp, `ict_grade` = @ictGrade, `ict_xp` = @ictXp, `maths_grade` = @mathsGrade, `maths_xp` = @mathsXp, `mechanics_grade` = @mechanicsGrade, `mechanics_xp` = @mechanicsXp, `is_working` = @isWorking, `work_timer_timeleft` = @workTimerTimeLeft, `has_phone` = @hasPhone, `is_dead` = @isDead, `death_timer_timeleft` = @deathTimerTimeLeft, `is_jailed` = @isJailed, `jail_timer_timeleft` = @jailTimerTimeLeft WHERE `id` = @id LIMIT 1");
                    dbClient.AddParameter("id", id);
                    dbClient.AddParameter("currentHealth", this.currentHealth);
                    dbClient.AddParameter("currentHunger", this.currentHunger);
                    dbClient.AddParameter("currentEnergy", this.currentEnergy);
                    dbClient.AddParameter("currentHygiene", this.currentHygiene);
                    dbClient.AddParameter("bankBalance", this.bankBalance);
                    dbClient.AddParameter("governmentGroup", GenerateRoleplayInstance.GetStringForGovernmentGroup(governmentGroup));
                    dbClient.AddParameter("killCount", this.killCount);
                    dbClient.AddParameter("deathCount", this.deathCount);
                    dbClient.AddParameter("hitsThrown", this.hitsThrown);
                    dbClient.AddParameter("hitsReceived", this.hitsReceived);
                    dbClient.AddParameter("totalCashEarned", this.totalCashEarned);
                    dbClient.AddParameter("fitnessLevel", this.fitnessLevel);
                    dbClient.AddParameter("fitnessXp", this.fitnessXp);
                    dbClient.AddParameter("strengthLevel", this.strengthLevel);
                    dbClient.AddParameter("strengthXp", this.strengthXp);
                    dbClient.AddParameter("overallGrade", this.educationGradeOverall);
                    dbClient.AddParameter("overallSkillLevel", this.skillLevelOverall);
                    dbClient.AddParameter("bloodType", GenerateRoleplayInstance.GetStringForBloodType(bloodType));
                    dbClient.AddParameter("healthServiceNumber", this.healthServiceNumber);
                    dbClient.AddParameter("nationalInsuranceNumber", this.nationalInsuranceNumber);
                    dbClient.AddParameter("businessId", this.businessId);
                    dbClient.AddParameter("businessPosition", this.businessPosition);
                    dbClient.AddParameter("govId", this.governmentId);
                    dbClient.AddParameter("cookingLevel", this.cookingLevel);
                    dbClient.AddParameter("cookingXp", this.cookingXp);
                    dbClient.AddParameter("fishingLevel", this.fishingLevel);
                    dbClient.AddParameter("fishingXp", this.fishingXp);
                    dbClient.AddParameter("farmingLevel", this.farmingLevel);
                    dbClient.AddParameter("farmingXp", this.farmingXp);
                    dbClient.AddParameter("miningLevel", this.miningLevel);
                    dbClient.AddParameter("miningXp", this.miningXp);
                    dbClient.AddParameter("woodcuttingLevel", this.woodcuttingLevel);
                    dbClient.AddParameter("woodcuttingXp", this.woodcuttingXp);
                    dbClient.AddParameter("englishGrade", this.englishGrade);
                    dbClient.AddParameter("englishXp", this.englishXp);
                    dbClient.AddParameter("scienceGrade", this.scienceGrade);
                    dbClient.AddParameter("scienceXp", this.scienceXp);
                    dbClient.AddParameter("ictGrade", this.ictGrade);
                    dbClient.AddParameter("ictXp", this.ictXp);
                    dbClient.AddParameter("mathsGrade", this.mathsGrade);
                    dbClient.AddParameter("mathsXp", this.mathsXp);
                    dbClient.AddParameter("mechanicsGrade", this.mechanicsGrade);
                    dbClient.AddParameter("mechanicsXp", this.mechanicsXp);
                    dbClient.AddParameter("isWorking", 0);
                    dbClient.AddParameter("workTimerTimeLeft", this.workTimerTimeLeft);
                    dbClient.AddParameter("hasPhone", this.hasPhone);
                    dbClient.AddParameter("isDead", (this.isDead == true ? 1 : 0));
                    dbClient.AddParameter("deathTimerTimeLeft", this.deathTimerTimeLeft);
                    dbClient.AddParameter("isJailed", (this.isJailed == true ? 1 : 0));
                    dbClient.AddParameter("jailTimerTimeLeft", this.jailTimerTimeLeft);
                    dbClient.RunQuery();
                }

                GC.SuppressFinalize(this);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
                System.Console.WriteLine(ex.StackTrace);
            }

它正在抛出如下的异常......

Error in query: 
UPDATE `roleplay_statistics` SET `current_health` = @currentHealth, `current_hunger` = @currentHunger, `current_energy` = @currentEnergy, `current_hygiene` = @currentHygiene, `bank_balance` = @bankBalance, `government_group` = @governmentGroup, `kill_count` = @killCount, `death_count` = @deathCount, `hits_thrown` = @hitsThrown, `hits_received` = @hitsReceived, `total_cash_earned` = @totalCashEarned, `current_fitness_level` = @fitnessLevel, `fitness_xp` = @fitnessXp, `current_strength_level` = @strengthLevel, `strength_xp` = @strengthXp, `education_grade_overall` = @overallGrade, `skill_level_overall` = @overallSkillLevel, `blood_type` = @bloodType, `health_service_number` = @healthServiceNumber, `national_insurance_number` = @nationalInsuranceNumber, `business_id` = @businessId, `business_position` = @businessPosition, `government_id` = @govId, `cooking_level` = @cookingLevel, `cooking_xp` = @cookingXp, `fishing_level` = @fishingLevel, `fishing_xp` = @fishingXp, `farming_level` = @farmingLevel, `farming_xp` = @farmingXp, `mining_level` = @miningLevel, `mining_xp` = @miningXp, `woodcutting_level` = @woodcuttingLevel, `woodcutting_xp` = @woodcuttingXp, `english_grade` = @englishGrade, `english_xp` = @englishXp, `science_grade` = @scienceGrade, `science_xp` = @scienceXp, `ict_grade` = @ictGrade, `ict_xp` = @ictXp, `maths_grade` = @mathsGrade, `maths_xp` = @mathsXp, `mechanics_grade` = @mechanicsGrade, `mechanics_xp` = @mechanicsXp, `is_working` = @isWorking, `work_timer_timeleft` = @workTimerTimeLeft, `has_phone` = @hasPhone, `is_dead` = @isDead, `death_timer_timeleft` = @deathTimerTimeLeft, `is_jailed` = @isJailed, `jail_timer_timeleft` = @jailTimerTimeLeft WHERE `id` = @id LIMIT 1
MySql.Data.MySqlClient.MySqlException (0x80004005): Data truncated for column 'is_working' at row 1
   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   at Plus.Database.Adapter.QueryAdapter.RunQuery() in C:\Users\Administrator\Desktop\Emulator\Database\Adapter\QueryAdapter.cs:line 177

列is_working是数据库中的枚举我正在运行此查询,选项为0或1,0 =否,1 =是。

0 个答案:

没有答案