[HELP]Problem in SaveChar

09/09/2008 14:48 silvestre#1
i have this in DataBase.cs Ln:1373 to ln:1388:
Code:
public static void SaveChar(Character Charr)
        {
            try
            {
                Charr.PackInventory();
                Charr.PackEquips();
                Charr.PackSkills();
                Charr.PackProfs();
                Charr.PackWarehouses();
                Charr.PackEnemies();
                Charr.PackFriends();

                MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `CharName` = '" + Charr.Name + "', `Level` = " + Charr.Level + ",`Exp` = " + Charr.Exp + ",`GuildDonation` = " + Charr.GuildDonation + ",`Strength` = " + Charr.Str + ",`Agility` = " + Charr.Agi + ",`Vitality` = " + Charr.Vit + ",`Spirit` = " + Charr.Spi + ",`Job` = " + Charr.Job + ",`Model` = " + Charr.Model + ",`Money` = " + Charr.Silvers + ",`CPs` = " + Charr.CPs + ",`CurrentHP` = " + Charr.CurHP + ",`StatPoints` = " + Charr.StatP + ",`MyGuild` = " + Charr.GuildID + ",`GuildPos` = " + Charr.GuildPosition + ",`LocationMap` = " + Charr.LocMap + ",`LocationX` = " + Charr.LocX + ",`LocationY` = " + Charr.LocY + ",`Hair` = " + Charr.Hair + ",`Equipment` = '" + Charr.PackedEquips + "',`Inventory` = '" + Charr.PackedInventory + "',`PKPoints` = " + Charr.PKPoints + ",`PrevMap` = " + Charr.PrevMap + ", `Skills` = '" + Charr.PackedSkills + "', `Profs` = '" + Charr.PackedProfs + "',`RBCount` = " + Charr.RBCount + ",`Avatar` = " + Charr.Avatar + ",`WHMoney` = " + Charr.WHSilvers + ",`VP` = " + Charr.VP + ",`Warehouses` = '" + Charr.PackedWHs + "',`Friends` = '" + Charr.PackedFriends + "',`Enemies` = '" + Charr.PackedEnemies + "' WHERE `Account` = '" + Charr.MyClient.Account + "'", Connection);
                Command.ExecuteNonQuery();

            }
            catch (Exception Exc) { General.WriteLine(Convert.ToString(Exc)); }
        }
and in my console why i this text:
Code:
System.InvalidOperationException: Connection must be valid and open
at Mysql.Data.Mysqlclient.MysqlCommand.checkstate<>
at mysql.data.mysqlclient.mysqlcommand.executenonquer y<>
at CoServer_project.Database.saveChar<Character Charr> in ... database.cs:line 1386
this problem don't save Characters... if online... :(

can you help me?
tks
09/09/2008 16:39 keving#2
System.InvalidOperationException: Connection must be valid and open
Says

Connection is not open or dont exit more dont to say
09/09/2008 18:44 silvestre#3
ok but the Code is correct... i don't understand why?!?!

tks
09/10/2008 00:59 tao4229#4
Both of you can't speak english, keving you're an idiot, DURR THE THING SAYS CONNECTION MUST BE OPEN, SO IT'S OBVIOUSLY NOT OPEN >.>

DataBase.cs is coded like SHIT. It takes some major fixing that I'm still trying to work out..