Exemplo n.º 1
0
        public bool ConnectionTest()
        {
            MySql.Data.MySqlClient.MySqlConnection connection = new global::MySql.Data.MySqlClient.MySqlConnection();

            connection.ConnectionString = _ConnectionString;
            try
            {
                MySql.Data.MySqlClient.MySqlCommand mycommand = new global::MySql.Data.MySqlClient.MySqlCommand();
                mycommand.Connection = connection;
                //  mycommand.CommandText = SQL_Statement;
                mycommand.CommandType = global::System.Data.CommandType.Text;
                mycommand.Connection.Open();

                if (mycommand.Connection.State != global::System.Data.ConnectionState.Open)
                {
                    return false;
                }
                else
                {
                    mycommand.Connection.Close();
                    if(connection!=null)
                    {
                        connection.Close();
                    }
                    return true;
                }
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); return false; }
        }