Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the error con.Open ();

C#
MySqlConnection con = new MySqlConnection("Server=db4free.net;Port=3306;database=moyabd;User Id=leshiy;Password=leshiy1996;charset=utf8");

            try
            {
                
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                    MySqlCommand cmd = new MySqlCommand("INSERT INTO tblTest(user,pass) VALUES(@user,@pass)", con);
                    
                    cmd.Parameters.AddWithValue("@user", etUsername.Text);
                    cmd.Parameters.AddWithValue("@pass", etPassword.Text);
                    cmd.ExecuteNonQuery();
                    txtSysLog.Text = "Регистрация прошла успешна";
                }
            }
            catch (MySqlException ex)
            {
                txtSysLog.Text = ex.ToString();
            }
            finally
            {
                con.Close();
            }


What I have tried:

I can not find the answer to the error.
Posted
Updated 24-May-18 18:10pm
v2
Comments
Bryian Tan 24-May-18 23:34pm    
what the error said?
RossMW 24-May-18 23:34pm    
and the error message is.....?
F-ES Sitecore 25-May-18 4:27am    
The problem is that your connection string is wrong. To fix it you have to supply the correct one. We can't possibly tell you what that is as we don't know what you're trying to connect to.

1 solution

Looks like you have just created another bigger problem:
C#
MySqlConnection con = new MySqlConnection("Server=db4free.net;Port=3306;database=moyabd;User Id=leshiy;Password=leshiy1996;charset=utf8");

This look like the public coordinates of your databases server along with username and password.
It recommend to change password as soon as possible.
If you publish the code like this:
C#
MySqlConnection con = new MySqlConnection("Server=db4free.net;Port=3306;database=moyabd;User Id=xxxxxx;Password=xxxxxxxxxx;charset=utf8");

Everyone will understand that they are fake.

For your question: tell us the Error message.
 
Share this answer
 

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

  Print Answers RSS


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