+ Reply to Thread
Results 1 to 5 of 5

Thread: mySQL startup

  1. #1
    thegriff is offline x10Hosting Member thegriff is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    14

    mySQL startup [Solved]

    My bad: I assumed "remote access" was for paid access only.

    Changing "localhost" in the connection string to "mysql.x10hosting.com" worked like a charm.
    Working connection string:
    "server=mysql.x10hosting.com;user id=thegriff_dummy;password=dummy;database=thegriff _testing;"

    Please note: "dummy" is no longer a valid user for any database under my control.





    I am a complete beginner at this, and have a problem, which has taken me all yesterday to get no-where on.

    I have created a mySQL database, called "testing" so accessed via "thegriff_testing" using myphpAdmin, and populated it.
    I have given it a user "dummy", with a password "dummy" - these will be removed when I get it working and go to a "proper" database.
    I have created a "bin" directory, and uploaded the "mySQL.Data.dll" assembly.
    I have duplicated this on my local machine.
    I have created some C# code to access the database:
    Code:
    privatevoid FillLabel()
    {
    string strFilter = "SELECT LastName, Donation FROM Supporters";
    string strConnect = AddResponse("server=" ,tbServer.Text);
    strConnect += AddResponse("user id=", tbUser.Text);
    strConnect += AddResponse("password=", tbPassword.Text);
    strConnect += AddResponse("database=", tbDatabase.Text);
    strConnect += AddResponse("" , tbOther.Text);
    if (strConnect.EndsWith(";"))
      {
      strConnect = strConnect.Substring(0, strConnect.Length - 1);
      }
    if (!string.IsNullOrEmpty(tbMinDonation.Text))
      {
      strFilter += " WHERE (Donation > " + tbMinDonation.Text + ")";
      }
    DataOutput.Text = "Supporter's Donations" + "<br/>";
    DataOutput.Text += "---------------------------" + "<br/>";
    DataOutput.Text += strConnect + "<br/>";
    try
      {
      hookUp = newMySqlConnection(strConnect);
      DataOutput.Text += "Connected<br/>";
      sqlCmd = newMySqlCommand(strFilter, hookUp);
      DataOutput.Text += "Command created<br/>";
      hookUp.Open();
      DataOutput.Text += "Opened<br/>";
      reader = sqlCmd.ExecuteReader();
      DataOutput.Text += "Executed<br/>";
    while (reader.Read())
         {
         dona = Convert.ToString(reader["Donation"]);
         ln = Convert.ToString(reader["LastName"]);
         DataOutput.Text += ln + " donated $" + dona + "<br/>";
         }
      }
    catch (Exception ex)
      {
      DataOutput.Text += ex.ToString();
      }
    finally
      {
    if (reader != null)
         {
         reader.Close();
         }
    if (hookUp != null)
         {
         hookUp.Close();
         }
      }
    }
    privatestring AddResponse(string p, string p_2)
    {
    if (string.IsNullOrEmpty(p_2))
      {
    returnnull;
      }
    return p + p_2 + ";";
    }
    When I run it locally, it works fine. When I run it on X10hosting, i get:
    Code:
    Supporter's Donations
    ---------------------------
    server=localhost;user id=thegriff_dummy;password=dummy;database=thegriff_testing;
    Connected
    Command created
    MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts. 
    ---> System.Net.Sockets.SocketException: 
           Connection refused at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remote_end)[0x00000]
           at System.Net.Sockets.Socket+Worker.Connect () [0x00000] 
    --- End of inner exception stack trace --- 
     
    at MySql.Data.MySqlClient.NativeDriver.Open ()[0x00000] 
    at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000] 
    at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection () [0x00000] 
    at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection () [0x00000] 
    at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver () [0x00000]
    I get the same regardless of "user id": I have tried "thegriff_dummy", "dummy" and completely unrelated ones with no change in message.
    Which seems to imply that it is a problem in actually connecting to mySQL.
    What have I forgotten to do?
    Last edited by thegriff; 10-05-2009 at 06:27 AM. Reason: Found solution.

  2. #2
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: mySQL startup

    Looking over your code, some spaces seem to be missing...

    It seems you are missing
    Code:
    hookUp.Open();
    after
    Code:
    hookUp = newMySqlConnection(strConnect);
    Last edited by xav0989; 10-05-2009 at 07:59 PM.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  3. #3
    thegriff is offline x10Hosting Member thegriff is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    14

    Re: mySQL startup

    Thanks for the sugestion, but it was already there, below the MySqlCommand constructor.
    As I said, it's sorted now, the problem was the connection string addressing "localhost" instead of "mysql.x10hosting"

    Code:
     
      hookUp = newMySqlConnection(strConnect);
      DataOutput.Text += "Connected<br/>";
      sqlCmd = newMySqlCommand(strFilter, hookUp);
      DataOutput.Text += "Command created<br/>";
      hookUp.Open();

  4. #4
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,438

    Re: mySQL startup

    It's interesting, as in php I still use localhost, but in ASP.net you seem to need to user mysql.x10hosting.com
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

  5. #5
    thegriff is offline x10Hosting Member thegriff is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    14

    Re: mySQL startup

    Mmm. It is all a little odd:

    php @ x10 = localhost
    asp.net @ x10 = myqsl.x10
    local machine asp.net mySQL = localhost
    local machine asp.net SQL = GRIFF\\SQLEXPRESS

    Go figure...:nuts:

    It's simple enough when you know what to use, but working it out from scratch is a real PITA!
    Last edited by thegriff; 10-07-2009 at 03:26 AM. Reason: Correction from "asp.net @ php" to "asp.net @ x10"
    No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.


    FOR SALE: Bargain! Large supply of slightly used '0's and '1's. Can be delivered electronically. Special rates for bulk purchases!

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. Replies: 14
    Last Post: 09-29-2008, 07:07 PM
  3. New Site-Suggestions?
    By mnoutside in forum Review My Site
    Replies: 9
    Last Post: 08-27-2008, 07:01 AM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM
  5. Have a problem with my forum
    By tikloos in forum Scripts & 3rd Party Apps
    Replies: 43
    Last Post: 01-19-2006, 01:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers