Saqi

Saqi

  • NA
  • 63
  • 122.6k

How can i check my connection string is able to open

May 30 2012 8:24 AM
MySqlConnection cnn = new MySqlConnection();
                cnn.ConnectionString += @"DataBase=" + dbhosts + ";";
                cnn.ConnectionString += @"User=" + usuario + ";";
                cnn.ConnectionString += @"Password=" + senha + ";";
                cnn.ConnectionString += @"DataSource=" + hosts[count] + ";";
                if ( cnn is able to open )
                {
                    cnn.Open();
                }
                else
                {
                    MessageBox.Show("HOST:" + hosts[count].ToString() + "DATABASE:" + dbhosts.ToString() + "\n\r" + "Recheck connection");
                }

before open i need to know if it right connection How?

Answers (2)