Need help :X

07/14/2009 06:29 AndreaCo#1
my server is changing sources from an ini source into a mysql source and i dont want to restart all the accounts.. so i just decided to code something in that will convert the main stuff like equips, levels and cps into the new mysql source.. i have the whole code with no errors but for some reason it wont update.

here is the code


Code:
public static void Transfer(Client UClient)
        {
            Ini Transfer = new Ini(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc");

            string CharName = Transfer.ReadValue("Account", "Charr");
            Ini CharInfo = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + CharName + ".chr");
            string equip = CharInfo.ReadValue("Character", "Equipment");
            Console.WriteLine("transfer in progress for account id " + UClient.Account + " and for char name " + CharName);

            string level1 = CharInfo.ReadValue("Character", "Level");
            string cps1 = CharInfo.ReadValue("Character", "CPs");
            MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `Level` = " + level1 +", `CPs` = " + cps1 +   ",`Equipment` = '" + equip, Connection);
            Command.ExecuteNonQuery();
        }
also i added the actual actication code under the Creat char.. so when someone creates the char with the same username it auto gives the stuff.. this is the code i put under the creat char

Code:
 if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc"))
                    {

                        DataBase.Transfer(UClient);
                       


                    }
anyways if u see any problem or know how to fix it id appreciate it.. thank you in advance ^^
07/14/2009 15:21 f0am#2
I'm not the best with ini but it seems to me like your not reading from the ini file.
07/14/2009 16:21 _tao4229_#3
For the MYSQL you need to `UPDATE` those fields WHERE something=something.
Example: [Only registered and activated users can see links. Click Here To Register...]

And if their account isn't in MySQL already you'll need to INSERT in the things instead of updating something that doesn't exist yet.
Example:[Only registered and activated users can see links. Click Here To Register...]
07/14/2009 17:00 nTL3fTy#4
Quote:
Originally Posted by f0am View Post
I'm not the best with ini but it seems to me like your not reading from the ini file.
Maybe you're just blind, cause I can see it just fine.
Code:
public static void Transfer(Client UClient)
        {
            [COLOR="Red"]Ini Transfer = new Ini(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc");[/COLOR]

            [COLOR="Red"]string CharName = Transfer.ReadValue("Account", "Charr");[/COLOR]
            Ini CharInfo = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + CharName + ".chr");
            string equip = CharInfo.ReadValue("Character", "Equipment");
            Console.WriteLine("transfer in progress for account id " + UClient.Account + " and for char name " + CharName);

            string level1 = CharInfo.ReadValue("Character", "Level");
            string cps1 = CharInfo.ReadValue("Character", "CPs");
            MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `Level` = " + level1 +", `CPs` = " + cps1 +   ",`Equipment` = '" + equip, Connection);
            Command.ExecuteNonQuery();
        }
Quote:
Originally Posted by AndreaCo View Post
my server is changing sources from an ini source into a mysql source and i dont want to restart all the accounts.. so i just decided to code something in that will convert the main stuff like equips, levels and cps into the new mysql source.. i have the whole code with no errors but for some reason it wont update.

here is the code


Code:
public static void Transfer(Client UClient)
        {
            Ini Transfer = new Ini(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc");

            string CharName = Transfer.ReadValue("Account", "Charr");
            Ini CharInfo = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + CharName + ".chr");
            string equip = CharInfo.ReadValue("Character", "Equipment");
            Console.WriteLine("transfer in progress for account id " + UClient.Account + " and for char name " + CharName);

            string level1 = CharInfo.ReadValue("Character", "Level");
            string cps1 = CharInfo.ReadValue("Character", "CPs");
            MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `Level` = " + level1 +", `CPs` = " + cps1 +   ",`Equipment` = '" + equip, Connection);
            Command.ExecuteNonQuery();
        }
also i added the actual actication code under the Creat char.. so when someone creates the char with the same username it auto gives the stuff.. this is the code i put under the creat char

Code:
 if (System.IO.File.Exists(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc"))
                    {

                        DataBase.Transfer(UClient);
                       


                    }
anyways if u see any problem or know how to fix it id appreciate it.. thank you in advance ^^
As for AndreaCo, why are you attempting to escape the backslash when the entire string is already escaped?
Code:
[COLOR="Red"]@[/COLOR]"\accounts[COLOR="Red"]\\[/COLOR]"
07/14/2009 17:23 f0am#5
Quote:
Originally Posted by nTL3fTy View Post
Maybe you're just blind, cause I can see it just fine.
Code:
public static void Transfer(Client UClient)
        {
            [COLOR=Red]Ini Transfer = new Ini(System.Windows.Forms.Application.StartupPath + @"\accounts\\" + UClient.Account + ".acc");[/COLOR]

            [COLOR=Red]string CharName = Transfer.ReadValue("Account", "Charr");[/COLOR]
            Ini CharInfo = new Ini(System.Windows.Forms.Application.StartupPath + @"\characters\\" + CharName + ".chr");
            string equip = CharInfo.ReadValue("Character", "Equipment");
            Console.WriteLine("transfer in progress for account id " + UClient.Account + " and for char name " + CharName);

            string level1 = CharInfo.ReadValue("Character", "Level");
            string cps1 = CharInfo.ReadValue("Character", "CPs");
            MySqlCommand Command = new MySqlCommand("UPDATE `Characters` SET `Level` = " + level1 +", `CPs` = " + cps1 +   ",`Equipment` = '" + equip, Connection);
            Command.ExecuteNonQuery();
        }
As for AndreaCo, why are you attempting to escape the backslash when the entire string is already escaped?
Code:
[COLOR=Red]@[/COLOR]"\accounts[COLOR=Red]\\[/COLOR]"

More like there is more than just rading name level cps and equipment. Also you dont have to be such an ass.
07/14/2009 20:53 AndreaCo#6
it reads the ini files just fine.. like i said my problem was it does not not update the mysql files.. lol
07/15/2009 01:50 f0am#7
Quote:
Originally Posted by AndreaCo View Post
it reads the ini files just fine.. like i said my problem was it does not not update the mysql files.. lol
well like i think saint said before, your not updating because you dont have them there, your inserting.

[Only registered and activated users can see links. Click Here To Register...]

or try tizag.com

or pm me and i can help u :D ill try my bestestttt
07/15/2009 03:06 danielachraf#8
Quote:
Originally Posted by f0am View Post
well like i think saint said before, your not updating because you dont have them there, your inserting.

[Only registered and activated users can see links. Click Here To Register...]

or try tizag.com

or pm me and i can help u :D ill try my bestestttt
:confused::confused::confused:
07/15/2009 11:31 tanelipe#9
PHP Code:
public static void Transfer(Client Client) {
    
Ini File = new Ini(Application.StartupPath "\\accounts\\" Client.Account ".acc"); 
    
string Name File.ReadValue("Account""Charr");
    
File = new Ini(Application.StartupPath "\\characters\\" Name ".chr");
    
string Equipment File.ReadValue("Character""Equipment");

    
string Level File.ReadValue("Character""Level");
    
string ConquerPoints File.ReadValue("Character""CPs");

    
    
string Query "INSERT Characters(Name, Level, Equipment, CPs) VALUES (`{0}`, {1}, {2}, {3})";
    
string FullQuery string.Format(QueryNameLevelEquipmentConquerPoints);
    
SendQuery(FullQuery);
}
public static 
void SendQuery(string Query) {
    
MySqlCommand SQLCommand = new MySqlCommand(QueryConnection);
    
SQLCommand.ExecuteNonQuery();

Bottom line is that you need to use "INSERT" instead of "UPDATE". The syntax may be a little off, not used to MySQL
07/17/2009 02:46 AndreaCo#10
nah i found out wat was wrong.. the code was right but when i added the catch thing to show me what the error was it said that the mysql wont support the transfer of equipment.. but the levels and cps transfered fine.. thx anyways ^^