1

When I debug through the code just hangs on connection.Open();

I am using the connector - using MySql.Data.MySqlClient;

Thanks in advance.

        string strProvider = "Data Source=" + host + ";Database=" + database + ";User ID=" + user + ";Password=" + password;

        MySqlConnection connection = new MySqlConnection(strProvider);
        MySqlCommand command = connection.CreateCommand();
        MySqlDataReader Reader;
        command.CommandText = "select * from products";
        connection.Open();
        Reader = command.ExecuteReader();
        while (Reader.Read())
        {

            string thisrow = "";
            for (int i = 0; i < Reader.FieldCount; i++)
                thisrow += Reader.GetValue(i).ToString() + ",";
            listBox1.Items.Add(thisrow);
        }
        connection.Close();
1
  • Try to set command.CommandTimeout, and see if you get a timeout. If you do, check if you can use telnet or netcat to connect SQLite. Commented Jan 20, 2011 at 7:37

1 Answer 1

3

This will help http://www.connectionstrings.com/mysql

You need to change your connection string for MySQL

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.