帮助解决代码中的问题。我只是无法理解它是什么 [英] Help to solve the problem in the code. I just can not understand what it is

查看:107
本文介绍了帮助解决代码中的问题。我只是无法理解它是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误con.Open();



 MySqlConnection con =  new  MySqlConnection(  Server = db4free.net; Port = 3306; database = moyabd; User Id = leshiy;密码= leshiy1996;字符集= UTF8\" ); 

尝试
{

if (con.State == ConnectionState.Closed)
{
con.Open();
MySqlCommand cmd = new MySqlCommand( INSERT INTO tblTest(用户,通过)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( );
}
最后
{
con.Close();
}





我的尝试:



我找不到错误的答案。

解决方案

看起来你刚刚创造了另一个更大的问题:

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



这看起来像数据库服务器的公共坐标以及用户名和密码。

建议尽快更改密码。

如果您发布代码如此这个:

 MySqlConnection con =  new  MySqlConnection(  Server = db4free.net; Port = 3306; database = moyabd; User Id = xxxxxx; Password = xxxxxxxxxx; charset = utf8); 



每个人都会明白他们是假的。



对于你的问题:告诉我们错误信息。


the error con.Open ();

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.

解决方案

Looks like you have just created another bigger problem:

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:

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.


这篇关于帮助解决代码中的问题。我只是无法理解它是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆