[Urgent] Attention to anyone using LOFT Source

09/21/2008 23:58 THE BAT#1
The MySQL .NET Connector has a bug, its not happen always, but it happen like 3 or 4 times a day, i search the MySQL Knowledge base and some report that bug too.

look at the errors:

Code:
MySql.Data.MySqlClient.MySqlException: Duplicate entry '' for key 1
   at MySql.Data.MySqlClient.MySqlStream.OpenPacket()
   at MySql.Data.MySqlClient.NativeDriver.ReadResult(UInt64& affectedRows, Int64& lastInsertId)
   at MySql.Data.MySqlClient.MySqlDataReader.GetResultSet()
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
Code:
System.ArgumentException: Column 'UID' does not belong to table Character.
   at System.Data.DataRow.GetDataColumn(String columnName)
   at System.Data.DataRow.get_Item(String columnName)

i suggest if you are planning to release your server to public, move to another database server like SQL Server.

cuz when that problem happen, some character information replace with 0 in the database
09/22/2008 00:10 © Haydz#2
Or a better idea... don't use lotf at all :)
09/22/2008 00:12 glupkotrup#3
Haha... I think 99.99% use the LOTF source :D
09/22/2008 00:17 THE BAT#4
Quote:
Originally Posted by © Haydz View Post
Or a better idea... don't use lotf at all :)
lol, nice idea
but i change it alot now, and implemenet alot of things, next i think i will move to SQL Server

LOL
09/22/2008 00:24 glupkotrup#5
Haha :D
09/22/2008 09:03 THE BAT#6
i convert my source to work with MS SQL Server, i used SQL Server Express SP2, and convert my current MySQL database.

i convert the Database class, and the server work more stable and more faster SQL Server

i just let all know
09/22/2008 17:10 reborn666#7
post ur
Quote:
public static void GetCharInfo(Character Charr, string UserName)
09/22/2008 19:14 stephanyd#8
Quote:
Originally Posted by THE BAT View Post
i convert my source to work with MS SQL Server, i used SQL Server Express SP2, and convert my current MySQL database.

i convert the Database class, and the server work more stable and more faster SQL Server

i just let all know
how to convert source to make it work with MS SQL Server ???
09/22/2008 20:50 © Haydz#9
Quote:
Originally Posted by stephanyd View Post
how to convert source to make it work with MS SQL Server ???
Convert.ToMSSql(object Source);
09/22/2008 22:31 THE BAT#10
The server is working very fine from more than 15 hours now, without any problem


Quote:
Originally Posted by reborn666 View Post
post ur
Quote:
public static void GetCharInfo(Character Charr, string UserName)
Here is my old GetCharInfo, i added some changes to it, in trying to stop losing chars, but the problem is with the MySQL .NET Connector, even with the latest version of it (5.2.3)

Code:
       public static void GetCharInfo(Character Charr, string UserName)
        {
            try
            {
                MySqlDataAdapter DataAdapter = null;
                DataSet DSet = new DataSet();                        

                DataAdapter = new MySqlDataAdapter("SELECT * FROM `Characters` WHERE `Account` = '" + UserName + "'", Connection);

                DataAdapter.Fill(DSet, "Character");

                if (DSet != null && DSet.Tables["Character"].Rows.Count > 0)
                {
                    DataRow DR = DSet.Tables["Character"].Rows[0];

                    Charr.UID = (uint)DR["UID"];
                    Charr.Name = (string)DR["CharName"];
                    Charr.Spouse = (string)DR["Spouse"];
                    Charr.Job = Convert.ToByte((uint)DR["Job"]);
                    Charr.Level = Convert.ToByte((uint)DR["Level"]);
                    Charr.Exp = (uint)DR["Exp"];
                    Charr.Model = Convert.ToUInt16((uint)DR["Model"]);
                    Charr.Avatar = Convert.ToUInt16((uint)DR["Avatar"]);
                    Charr.Hair = Convert.ToUInt16((uint)DR["Hair"]);
                    Charr.LocX = Convert.ToUInt16((uint)DR["LocationX"]);
                    Charr.LocY = Convert.ToUInt16((uint)DR["LocationY"]);
                    Charr.LocMap = Convert.ToUInt16((uint)DR["LocationMap"]);
                    Charr.Str = Convert.ToUInt16((uint)DR["Strength"]);
                    Charr.Agi = Convert.ToUInt16((uint)DR["Agility"]);
                    Charr.Vit = Convert.ToUInt16((uint)DR["Vitality"]);
                    Charr.Spi = Convert.ToUInt16((uint)DR["Spirit"]);
                    Charr.Silvers = (uint)DR["Money"];
                    Charr.CPs = (uint)DR["CPs"];
                    Charr.CurHP = Convert.ToUInt16((uint)DR["CurrentHP"]);
                    Charr.CurMP = Convert.ToUInt16((uint)DR["CurrentMP"]);
                    Charr.PKPoints = Convert.ToUInt16((uint)DR["PKPoints"]);
                    Charr.RBCount = Convert.ToByte((uint)DR["RBCount"]);
                    Charr.PackedInventory = (string)DR["Inventory"];
                    Charr.PackedEquips = (string)DR["Equipment"];
                    Charr.PackedSkills = (string)DR["Skills"];
                    Charr.PackedProfs = (string)DR["Profs"];
                    Charr.WHSilvers = (uint)DR["WHMoney"];
                    Charr.PackedWHs = (string)DR["Warehouses"];
                    Charr.PackedFriends = (string)DR["Friends"];
                    Charr.PackedEnemies = (string)DR["Enemies"];
                    Charr.VP = (uint)DR["VP"];
                    Charr.GuildDonation = (uint)DR["GuildDonation"];
                    Charr.GuildID = Convert.ToUInt16((uint)DR["MyGuild"]);
                    Charr.GuildPosition = Convert.ToByte((uint)DR["GuildPos"]);
                    Charr.PrevMap = Convert.ToUInt16((uint)DR["PrevMap"]);
                    if (Guilds.AllGuilds.ContainsKey(Charr.GuildID))
                        Charr.MyGuild = Guilds.AllGuilds[Charr.GuildID];
                    Charr.MinAtk = Charr.Str;
                    Charr.MaxAtk = Charr.Str;
                    Charr.Potency = Charr.Level;
                    Charr.RealModel = Charr.Model;
                    Charr.RealAvatar = Charr.Avatar;
                    Charr.MaxHP = Charr.BaseMaxHP();
                    Charr.MaxMP = Charr.MaxMana();
                    Charr.RealAgi = Charr.Agi;

                    Charr.KO = Convert.ToUInt16((uint)DR["KO"]);
                    Charr.OldKO = Convert.ToUInt16((uint)DR["OldKO"]);
                }
                else
                {
                    General.WriteLine("Char not found.");

                    throw new Exception();
                }
            }
            catch (Exception Exc) 
            {
                Charr = null;
                throw Exc; 
            }
        }
Quote:
Originally Posted by stephanyd View Post
how to convert source to make it work with MS SQL Server ???
i can give your the modified Database class to work with MS SQL Server, if you want
09/22/2008 22:50 stephanyd#11
Quote:
Originally Posted by THE BAT View Post
The server is working very fine from more than 15 hours now, without any problem




Here is my old GetCharInfo, i added some changes to it, in trying to stop losing chars, but the problem is with the MySQL .NET Connector, even with the latest version of it (5.2.3)

Code:
       public static void GetCharInfo(Character Charr, string UserName)
        {
            try
            {
                MySqlDataAdapter DataAdapter = null;
                DataSet DSet = new DataSet();                        

                DataAdapter = new MySqlDataAdapter("SELECT * FROM `Characters` WHERE `Account` = '" + UserName + "'", Connection);

                DataAdapter.Fill(DSet, "Character");

                if (DSet != null && DSet.Tables["Character"].Rows.Count > 0)
                {
                    DataRow DR = DSet.Tables["Character"].Rows[0];

                    Charr.UID = (uint)DR["UID"];
                    Charr.Name = (string)DR["CharName"];
                    Charr.Spouse = (string)DR["Spouse"];
                    Charr.Job = Convert.ToByte((uint)DR["Job"]);
                    Charr.Level = Convert.ToByte((uint)DR["Level"]);
                    Charr.Exp = (uint)DR["Exp"];
                    Charr.Model = Convert.ToUInt16((uint)DR["Model"]);
                    Charr.Avatar = Convert.ToUInt16((uint)DR["Avatar"]);
                    Charr.Hair = Convert.ToUInt16((uint)DR["Hair"]);
                    Charr.LocX = Convert.ToUInt16((uint)DR["LocationX"]);
                    Charr.LocY = Convert.ToUInt16((uint)DR["LocationY"]);
                    Charr.LocMap = Convert.ToUInt16((uint)DR["LocationMap"]);
                    Charr.Str = Convert.ToUInt16((uint)DR["Strength"]);
                    Charr.Agi = Convert.ToUInt16((uint)DR["Agility"]);
                    Charr.Vit = Convert.ToUInt16((uint)DR["Vitality"]);
                    Charr.Spi = Convert.ToUInt16((uint)DR["Spirit"]);
                    Charr.Silvers = (uint)DR["Money"];
                    Charr.CPs = (uint)DR["CPs"];
                    Charr.CurHP = Convert.ToUInt16((uint)DR["CurrentHP"]);
                    Charr.CurMP = Convert.ToUInt16((uint)DR["CurrentMP"]);
                    Charr.PKPoints = Convert.ToUInt16((uint)DR["PKPoints"]);
                    Charr.RBCount = Convert.ToByte((uint)DR["RBCount"]);
                    Charr.PackedInventory = (string)DR["Inventory"];
                    Charr.PackedEquips = (string)DR["Equipment"];
                    Charr.PackedSkills = (string)DR["Skills"];
                    Charr.PackedProfs = (string)DR["Profs"];
                    Charr.WHSilvers = (uint)DR["WHMoney"];
                    Charr.PackedWHs = (string)DR["Warehouses"];
                    Charr.PackedFriends = (string)DR["Friends"];
                    Charr.PackedEnemies = (string)DR["Enemies"];
                    Charr.VP = (uint)DR["VP"];
                    Charr.GuildDonation = (uint)DR["GuildDonation"];
                    Charr.GuildID = Convert.ToUInt16((uint)DR["MyGuild"]);
                    Charr.GuildPosition = Convert.ToByte((uint)DR["GuildPos"]);
                    Charr.PrevMap = Convert.ToUInt16((uint)DR["PrevMap"]);
                    if (Guilds.AllGuilds.ContainsKey(Charr.GuildID))
                        Charr.MyGuild = Guilds.AllGuilds[Charr.GuildID];
                    Charr.MinAtk = Charr.Str;
                    Charr.MaxAtk = Charr.Str;
                    Charr.Potency = Charr.Level;
                    Charr.RealModel = Charr.Model;
                    Charr.RealAvatar = Charr.Avatar;
                    Charr.MaxHP = Charr.BaseMaxHP();
                    Charr.MaxMP = Charr.MaxMana();
                    Charr.RealAgi = Charr.Agi;

                    Charr.KO = Convert.ToUInt16((uint)DR["KO"]);
                    Charr.OldKO = Convert.ToUInt16((uint)DR["OldKO"]);
                }
                else
                {
                    General.WriteLine("Char not found.");

                    throw new Exception();
                }
            }
            catch (Exception Exc) 
            {
                Charr = null;
                throw Exc; 
            }
        }


i can give your the modified Database class to work with MS SQL Server, if you want
thanks.. that would be great ..i just installed MS SQL Server express ;)
09/22/2008 23:00 ~Yuki~#12
Hmm may i should do it too...

Do i need the server express thngy?
09/22/2008 23:07 THE BAT#13
Quote:
Originally Posted by lolmaster123 View Post
Hmm may i should do it too...

Do i need the server express thngy?
yes, you need MS SQL Express, i installed 2005 SP2, cuz may be 2008 not yet stable like 2005.
09/22/2008 23:26 tao4229#14
... It's not that hard to get this to work with mysql, you can get it to work stable and all... It's just the way mysql works in lotf is crap.
09/23/2008 00:10 THE BAT#15
Quote:
Originally Posted by tao4229 View Post
... It's not that hard to get this to work with mysql, you can get it to work stable and all... It's just the way mysql works in lotf is crap.
The problem is not in LOTF Database code, you are true the code had one problem, but i fix it, i trace the code, but the problem is in the MySQL .NET Connector, and there are alot of people post it in the mySql forums, the thing is the problem happen randomly