2
Answers

How can i check my connection string is able to open

Saqi

Saqi

12y
998
1
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)