MySQL connection to remote host

Discussion in 'Databases' started by Terryj1974, Mar 24, 2006.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hello everyone:

    Does anyone know how to connect to a MySQL database outside of mydiscount asp? Since I already have a MySQL database running on another server, I wanted to see if anyone knew how to connect to it (ie what ODBC drivers are we running, etc).

    Thank you in advance for your help!

    Terry
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    You should be able to do that as long as the network hosting the MySQL do not block external access.


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Good evening everyone:

    I finally found the answer! If you need to an example for any type of connection string, please go to http://www.connectionstrings.com/

    Attached is some sample code that I got to run successfully!

    <%@ Page Language="C#" AutoEventWireup="False"
    EnableSessionState="False" EnableViewState="False" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.Odbc" %>
    <script runat="server">
    private const string ConnStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=<hostname>;PORT=3306;DATABASE=<dbname>;USER=<user>;PASSWORD=<password>;OPTION=3;";
    protected override void OnInit(EventArgs e)
    {
    base.OnInit(e);
    using(OdbcConnection con = new OdbcConnection(ConnStr))
    using(OdbcCommand cmd = new OdbcCommand("SELECT * FROM singles", con))
    {
    con.Open();
    dgrAllNames.DataSource = cmd.ExecuteReader(
    CommandBehavior.CloseConnection |
    CommandBehavior.SingleResult);
    dgrAllNames.DataBind();
    }
    }
    </script>
    <html>
    <head>
    <title>Displaying Records from MySQL 'Names' table</title>
    <style>
    body { font: 100% Verdana; }
    </style>
    </head>

    <p align="center">All records in the 'Names' table:</p>
    <asp:DataGrid ID="dgrAllNames" HorizontalAlign="Center"
    CellPadding="3" Runat="server" />
    </body>
    </html>

    If you are running MySQL 5, you may recieve an error that says<!--StartFragment --> "Client does not support authentication protocol requested
    by server; consider upgrading MySQL client"If you do, please go to http://dev.mysql.com/doc/refman/5.0/en/old-client.html - this will walk you through the solution.Happy Coding!!Terry
     
  4. I'm having the same problem. My connection looks exactly like what you have listed, but I'm still getting this problem:


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


    What version ofODBC 3.51 is being used here? I think the latest is 3.51.11.


    Thanks,


    Randy
     
  5. Bruce

    Bruce DiscountASP.NET Staff

    are you connecting to our mySQL server or to a remote mySQL server?


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  6. I'm connecting to a remote MySQL 5.0.x server.



    Post Edited (Randy) : 10/3/2006 6:17:34 AM GMT
     
  7. Bruce

    Bruce DiscountASP.NET Staff

    hmm.. this should work...

    I checked on the version of ODBC driver, it is v 3.51.06

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  8. Well, it doesn't seem to be working for me. Can we move to 3.51.11?


    Thanks,


    Randy
     
  9. Bruce

    Bruce DiscountASP.NET Staff

    i'll forward your request to our system admin.

    In order for us to update any software on our server, we have to thoroughly test it in our dev environment first.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
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