locked
Connecting to remote MySQL database RRS feed

  • Question

  • User-1363685831 posted

    I have many years of experience with VB.NET but I am relatively new to ASP.NET.  This is my first post here.

    I am trying to connect to a remote MySQL database with an ASP.NET page with VB.NET code behind it and I am having all kinds of strange problems.  I think all I need is to get the connection string right.  This example includes all of the options I have been trying:

    MySQLconn = New MySqlConnection("server=mysql.mydomain.com;port=3306;user=username;pwd=password;database=databasename;pooling=false;")

    <div id=":zu">Tried "user", "user id" and "uid"
    Tried "password" and "pwd"
    Tried with and without the port
    Tried with and without the pooling (without setting it to false, I get all kinds of other errors)
    Tried with database and without</div> <div>Tried with "mysql.mydomain.com" and "mydomain.com"
    Tried with different databases, different users, changing those users' passwords (yes, I was grasping at straws...)</div>

    I get:

    MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. at MySql.Data.MySqlClient.NativeDriver.Open() at MySql.Data.MySqlClient.Driver.open() at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.MySqlConnection.Open() at button_click_event(Object sender, EventArgs e) in code_filename:line 70 at server=mysql.mydomain.com;database=database;user=username;password=password;pooling=false

    I have tried the .NET Connector from the MySQL web site as I have with my desktop VB.NET applications for years.  I can connect to this database with PHP and I can ping mysql.mydomain.com, yet I cannot telnet the server nor have I gotten it to connect with ASP.NET.  I have been on Google and all over the internet for DAYS and I am slowly going insane...

    Can anyone offer me any assistance?  I would be MOST appreciative.

    Humbly,

    Shaun

    Friday, December 28, 2012 12:04 AM

Answers

  • User-718146471 posted

    Try it this way:

    Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

    You don't need to specify the port if you are using 3306 since that is the default.

    From: http://connectionstrings.com/mysql

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 28, 2012 6:21 AM

All replies

  • User-718146471 posted

    Try it this way:

    Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

    You don't need to specify the port if you are using 3306 since that is the default.

    From: http://connectionstrings.com/mysql

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 28, 2012 6:21 AM
  • User-1363685831 posted

    Thank you so much for responding.  This is one of them that I have tried and I get the following:

    MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. at MySql.Data.MySqlClient.NativeDriver.Open() at MySql.Data.MySqlClient.Driver.Open() at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() at MySql.Data.MySqlClient.MySqlPool.GetConnection() at MySql.Data.MySqlClient.MySqlConnection.Open() at walter_asp.WebForm1.Button1_Click(Object sender, EventArgs e)

    Any other thoughts?

    Friday, December 28, 2012 6:54 PM
  • User-1363685831 posted

    I was finally able tonight to get in touch with someone at my hosting company.  It appears I was having some kind of strange DNS issue...

    Your string was correct and I appreciate your reply.  Have a great weekend and a happy and safe New Year!

    Shaun

    Saturday, December 29, 2012 12:50 AM