Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,my friends!

I have a question.
I write a program using c#,it connect MySQL so slowly at the first time.
I don't know why and i need a solution.
Please help me!

my code:
C#
public Form1()
        {
            InitializeComponent();
            if (File.Exists(".\\system\\user.ini"))
            {
                StringBuilder temp = new StringBuilder(255);
                int i = GetPrivateProfileString("USER_ID", "ID", "", temp,
                                                255, ".\\system\\user.ini");
                this.textBox_login_username.Text = temp.ToString();
            }
            else
            {
                if (!Directory.Exists(".\\system\\"))
                {
                    Directory.CreateDirectory(".\\system\\");
                }
                WritePrivateProfileString("USER_ID", "ID", "", ".\\system\\user.ini");
            }
            client.user_lastloginip = GetLocalIP();

            string MyConnectionString = "Server=109.130.15.111;Database=repairfunction;Uid=pesystem;Pwd=tstcpe;pooling=true;CharSet=utf8;port=1081";
            MySqlConnection connection = new MySqlConnection(MyConnectionString);
            try
            {
                connection.Open();
            }
            finally
            {
                connection.Close();
            }
            this.textBox_login_password.Select();
        }


Thank you very much!
Posted
Updated 16-Jan-14 18:26pm
v2
Comments
ZurdoDev 16-Jan-14 20:57pm    
Perhaps because MySql is sitting idle. You would have to share your relevant code to see if it is a code problem.
aolin.wang 17-Jan-14 0:27am    
hi,i add code in my qusetion.
ZurdoDev 17-Jan-14 7:14am    
Debug it and find out which part is real slow.
Philippe Mori 16-Jan-14 22:31pm    
Because the first time, SQL engine has to be started and the connection made to the database... but it should not take more that a few seconds at most.
aolin.wang 17-Jan-14 0:32am    
yes,you are right.but MFC connect MySQL much faster than C#!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900