“mysql_native_password”失败,无法访问服务器(ASP.NET)

时间:2015-11-20 19:26:37

标签: mysql asp.net

我正在创建一个ASP.NET网页,在执行插入时,程序会给我以下错误:

msql_native_password error

我的代码是:

 Imports MySql.Data.MySqlClient
 Imports MySql.Data

 Partial Class RegistracionNueva
 Inherits System.Web.UI.Page

 Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim conexion As New MySqlConnection
    Dim adapter As MySqlDataAdapter
    Dim consulta, nombre, apellido, sexo, nacimiento, pais, telefono, email, pass As String
    nombre = Request.Form("nombre")
    apellido = Request.Form("apellido")
    sexo = Request.Form("radio1")
    nacimiento = Request.Form("fechanac")
    pais = Request.Form("Pais")
    telefono = Request.Form("pref") + Request.Form("telefono")
    email = Request.Form("correo")
    pass = Request.Form("pass")
    conexion.ConnectionString = "server=XXX;database=XXX;user id=XXX;password=XXX"
    Try       
        consulta = "Insert into Clientes('Nombre','Apellido','Sexo','Fecha_Nacimiento','Pais','Telefono','Email','Contrasena')VALUES('" & nombre & "','" & apellido & "','" & sexo & "','" & nacimiento & "','" & pais & "','" & telefono & "','" & email & "','" & pass & "')"
        conexion.Open()
        adapter = New MySqlDataAdapter(consulta, conexion)
        conexion.Close()
    Catch ex As Exception
        MsgBox(ex.ToString())
        conexion.Close()
    End Try
    Server.Transfer("Registrado.aspx", True)
End Sub
End Class

我认为这可能不是给我带来问题的联系......谁知道我的查询或任何程序都不正确。

我应该添加或更改哪些内容?

2 个答案:

答案 0 :(得分:0)

很确定这是你的连接字符串。它不应该有一个空间。尝试:

"server=XXX;database=XXX;uid=XXX;pwd=XXX"

答案 1 :(得分:0)

抱歉,我已经可以解决了!问题是同一个服务器,我告诉我的问题给帐户的所有者(服务器)并问我我的IP地址..现在我可以安全访问!

谢谢大家!