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:
When I run it locally, it works fine. When I run it on X10hosting, i get: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 + ";"; }
I get the same regardless of "user id": I have tried "thegriff_dummy", "dummy" and completely unrelated ones with no change in message.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]
Which seems to imply that it is a problem in actually connecting to mySQL.
What have I forgotten to do?


LinkBack URL
About LinkBacks
Reply With Quote
icon below! (this is even better than "liking" a post)

