Cannot connect to MySQL database from ASP code

Discussion in 'ASP.NET / ASP.NET Core' started by knguyen, Jun 3, 2011.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. We have been trying to test the connection from our ASP code to MySQL database on the host using the code below but we cannot connect and receive the error message:

    Microsoft OLE DB Provider for ODBC Drivers error '80004005'

    [MySQL][ODBC 3.51 Driver]Client does not support authentication protocol requested by server; consider upgrading MySQL client

    Connection test code:

    <%
    Dim sConnection
    Dim oConnection
    Dim oRS

    'sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=mysql501.discountasp.net; PORT=3306; DATABASE='db'; UID='uid'; PASSWORD='password'; OPTION=3"


    Set oConnection = Server.CreateObject("ADODB.Connection")
    oConnection.Open(sConnection)
    Set oRS = oConnection.Execute("SELECT * FROM TableName1")

    While Not oRS.EOF
    Response.Write oRS ("ID") & " " & oRS ("Name") & " "
    oRS.MoveNext
    Wend

    oRS.Close
    Set oRS = Nothing
    oConnection.Close
    Set oConnection = Nothing
    %>

    We tested this on IIS7, and it failed. We then migrate down to IIS6 but it still fails to connect. Can anyone help us on this?
     
  2. We have also tried to use the code provided in the Knowledge Base:
    <%
    Dim cnnSimple ' ADO connection
    Dim rstSimple ' ADO recordset
    Set cnnSimple = Server.CreateObject("ADODB.Connection")

    ' DSN
    cnnSimple.Open "DSN=<username>_mysqlConn;"

    Set rstSimple = cnnSimple.Execute("SELECT * FROM tblTest")


    %>
    <P> Connecting to mySQL DB with ODBC DSN </P>

    <table border="1">
    <%
    Do While Not rstSimple.EOF
    %>
    <tr>
    <td><%= rstSimple.Fields("id").Value %></td>
    <td><%= rstSimple.Fields("name").Value %></td>
    </tr>
    <%
    rstSimple.MoveNext
    Loop
    %>
    </table>
    <%
    ' Close our recordset and connection and dispose of the objects rstSimple.Close Set rstSimple = Nothing cnnSimple.Close Set cnnSimple = Nothing

    cnnSimple.close
    %>

    But it does not work either. To our understanding, we have to create a DSN to allow this code to connect to a specified database, but we dont see any feature on the CPanel allowing us to do so
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    You need to use the 5.1 driver.
     
  4. got it work :) thank for your support
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page