【问题标题】:MYSQL Connector not connectingMYSQL 连接器未连接
【发布时间】:2017-03-18 21:17:39
【问题描述】:

我在 c# 中有这个代码 atm 并且 MYSQL 连接不起作用:

int chk;
MySqlConnection con = new MySqlConnection(@"Data Source=sql9.freemysqlhosting.net;port=3306;Initial Catalog=new;UserId=sql9FFFFF9;password=X3FFFFYX8;");
con.Open();
MySqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from sql9164489.users where username='" + txt_user.Text + "' and password='" + txt_pass.Text + "'";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(dt);
chk = Convert.ToInt32(dt.Rows.Count.ToString());
//If Correct
if (chk == 1)
{
    MessageBox.Show("Connected");
}
else
{
    MessageBox.Show("Incorrect");
}
con.Close();

【问题讨论】:

    标签: c# mysql


    【解决方案1】:

    con.Operan() 引发错误:

    使用方法“mysql_native_password”对用户“sql9FFFFF9”的主机“sql9.freemysqlhosting.net”进行身份验证失败,并显示消息:用户“sql9FFFFF9”@“188.244.39.23”的访问被拒绝(使用密码:YES)

    我想这很清楚

    【讨论】:

      【解决方案2】:

      下载 .net 的 MySQL 连接器,您的工作将更加轻松,因为数据库将显示在服务器资源管理器中,然后您可以从那里复制和粘贴连接字符串。 Here is link

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-08-17
        • 1970-01-01
        • 2011-06-19
        • 2018-03-24
        • 2012-10-11
        • 2020-07-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多