How do I connect mvc to a non-local mySQL database?

Problem :

I have added this connection information into both the Webconfig in the same file level as the views folder, and the one in the views folder. It is also in the Web.Debug.config.

<add name="MySqlServer"

And then I have this function I copy pasted from a how-to that crashes on adapter.Fill(ds) because of a MySqlException "Unable to connect to any of the specified MySQL hosts." when I open /data/details/1

    // GET: /Data/Details
    public string Details()
        // Get the MySQL connection string stored in the Web.config
        string cnnString = ConfigurationSettings.AppSettings["ConnectionString"];

        // Create a connection object and data adapter
        MySqlConnection cnx = new MySqlConnection(cnnString);
        MySqlDataAdapter adapter = new MySqlDataAdapter();

        // Create a SQL command object
        string cmdText = "select '3232' as ah;";
        MySqlCommand cmd = new MySqlCommand(cmdText, cnx);

        // Set the command type to StoredProcedure
        cmd.CommandType = CommandType.StoredProcedure;

        // Create and fill a DataSet
        DataSet ds = new DataSet();
        adapter.SelectCommand = cmd;

        return "::::";

My test sql table is on my website rather than localhost, and is as follows

a   b   c
1   2013-02-02 14:08:53 324
2   2013-02-02 14:08:53 342234

I had followed a guide here: but am not sure if I found the right file to edit. I also set permission on dreamhost for my computer to access it.

Update: cnnString is coming up NULL

Solution :

Found out that ConfigurationSettings should be ConfigurationManager and set the line of code to be

string cnnString = ConfigurationManager.ConnectionStrings["MySqlServer"].ToString(); 

where "MySqlServer" matches the connectionstring name in the config file.

This was a good help: C# Configuration Manager . ConnectionStrings

Mysql Tutorials

Mysql Howto..

How can I copy rows from one to another table with a different number of columns

How to dynamically change content with php ajax and mysql

How do I turn cascade on delete ON by default , for MySQL?

SQL Optimization : How to optimize the query in MySQL?

How to make MySQL command line works with MAMP?

How can I simulate a print statement in MySQL?

How to capture a timestamp in MySql programmatically?

How to display hierarchical “NESTED SET” data with PHP?

how to make a queue in php with mysql

MySQL - How to alter part of a table element while keeping part of it the same

How to add MySQL connection file to check the database connection ?

how to indent results of mysql SELECT INTO OUTFILE

MySQL - How do I get a range from the point closest to start?

Surnames with quotes breaking SQL query, how to fix this? [duplicate]

PHP - How to change datetime from UTC when pulling data from MYSQL into JSON?

How to decode mysql_real_escape_string

How to duplicate a table with keys & other structure features retained in MySQL?

MySQL - How to order a joined table?

How to change mysql max execution time for console

how i insert 1 data with 2 string? and insert into database?

How to give two or where condition in mysql query in codeigniter

How to overwrite old entry with newer one in mysql table?

How to generate the highest number from one column in mysql database with php

show the list of selected id in mysql php

How to avoid implicit conversion of MySQL (Truncated incorrect DOUBLE value)

How select these specific rows in MySQL?

how to select all tables with column name and update that column

how to add a sub select query

How to atomically move rows from one table to another?

How to separate arrays into variables