title: Check MySql Connection is Opened Or Not in Visual C++
body: <p>Sorry, If u filling bored. I have searched on several search engines but could not got any result. Anyway I am working in an App which database is mysql. Now I have created a database wrapper class and want to check if the connection is already opened. Could u help me?</p>
  
  <pre><code>             String^ constring = L"datasource=localhost;port=3306;username=root;password=pass;database=eps;";
               String^ my_query = L"select id from eps_users where usr = '" + this-&gt;user_name-&gt;Text + "' and psw = md5('" + this-&gt;pass_word-&gt;Text + "');";
               MySqlConnection^ conDatabase = gcnew MySqlConnection(constring);
               MySqlCommand^ cmd = gcnew MySqlCommand(my_query, conDatabase);
               MySqlDataReader^ myreader;
               try
               {
                   conDatabase-&gt;Open();
                   myreader = cmd-&gt;ExecuteReader();
                   int count = 0;
                   while (myreader-&gt;Read())
                   {
                       count = count + 1;
  
               }
               if (count == 1){
                   MessageBox::Show("Username And Password is correct.", "Success", MessageBoxButtons::OK,
                       MessageBoxIcon::Information);
                   this-&gt;Hide();
                   Form2^ f2 = gcnew Form2(constring);
                   f2-&gt;ShowDialog();
               }
               else{
                   MessageBox::Show("Username And Password is not correct.", "Error", MessageBoxButtons::OK,
                       MessageBoxIcon::Error);
                   // &lt;del&gt;
                   this-&gt;Hide();
                   Form2^ f2 = gcnew Form2(constring);
                   f2-&gt;ShowDialog();
                   // &lt;/del&gt;
               }
           }
           catch (Exception^ ex)
           {
               MessageBox::Show(ex-&gt;Message);
           }
           conDatabase-&gt;Close();
  </code></pre>
  
  <p>I need to check if( conDatabase->HasBeenOpened()) { conDatabase->Open();}</p>