public static void CreateCharacter(Realm.Characters.Character character) { lock (DatabaseHandler.ConnectionLocker) { var sqlText = "INSERT INTO dyn_characters VALUES(@id, @name, @level, @class, @sex, @color, @color2, @color3, @mapinfos, @stats, @items, @spells, @exp)"; var sqlCommand = new MySqlCommand(sqlText, DatabaseHandler.Connection); var P = sqlCommand.Parameters; P.Add(new MySqlParameter("@id", character.ID)); P.Add(new MySqlParameter("@name", character.Name)); P.Add(new MySqlParameter("@level", character.Level)); P.Add(new MySqlParameter("@class", character.Class)); P.Add(new MySqlParameter("@sex", character.Sex)); P.Add(new MySqlParameter("@color", character.Color)); P.Add(new MySqlParameter("@color2", character.Color2)); P.Add(new MySqlParameter("@color3", character.Color3)); P.Add(new MySqlParameter("@mapinfos", character.MapID + "," + character.MapCell + "," + character.Dir)); P.Add(new MySqlParameter("@stats", character.SqlStats())); P.Add(new MySqlParameter("@items", "")); P.Add(new MySqlParameter("@spells", "")); P.Add(new MySqlParameter("@exp", 0)); sqlCommand.ExecuteNonQuery(); character.isNewCharacter = false; } }
public static void SaveCharacter(Realm.Characters.Character character) { lock (DatabaseHandler.ConnectionLocker) { var sqlText = "UPDATE dyn_characters SET id=@id, name=@name, level=@level, class=@class, sex=@sex," + " color=@color, color2=@color2, color3=@color3, mappos=@mapinfos, stats=@stats, items=@items, spells=@spells, experience=@exp WHERE id=@id"; var sqlCommand = new MySqlCommand(sqlText, DatabaseHandler.Connection); var P = sqlCommand.Parameters; P.Add(new MySqlParameter("@id", character.ID)); P.Add(new MySqlParameter("@name", character.Name)); P.Add(new MySqlParameter("@level", character.Level)); P.Add(new MySqlParameter("@class", character.Class)); P.Add(new MySqlParameter("@sex", character.Sex)); P.Add(new MySqlParameter("@color", character.Color)); P.Add(new MySqlParameter("@color2", character.Color2)); P.Add(new MySqlParameter("@color3", character.Color3)); P.Add(new MySqlParameter("@mapinfos", character.MapID + "," + character.MapCell + "," + character.Dir)); P.Add(new MySqlParameter("@stats", character.SqlStats())); P.Add(new MySqlParameter("@items", character.GetItemsToSave())); P.Add(new MySqlParameter("@spells", character.SpellsInventary.SaveSpells())); P.Add(new MySqlParameter("@exp", character.Exp)); sqlCommand.ExecuteNonQuery(); } }