示例#1
0
        //open connection to database
        public bool OpenConnection()
        {
            try
            {
                if (_connection.ConnOpend() || _connection.OpenConn())
                {
                    return(true);
                }
                return(false);
            }
            catch (MySqlException ex)
            {
                switch (ex.Number)
                {
                case 0:
                    MessageBox.Show("Cannot connect to server.  Contact administrator");
                    break;

                case 1045:
                    MessageBox.Show("Invalid username/password, please try again");
                    break;
                }
                return(false);
            }
        }
示例#2
0
        private void btnTestLink_Click(object sender, EventArgs e)
        {
            ConnectMySqlCloud con = new ConnectMySqlCloud(txtserver.Text, txtDatabase.Text, txtAccount.Text, txtpassword.Text);

            try
            {
                if (con.ConnOpend() || con.OpenConn())
                {
                    MessageBox.Show("链接数据库成功!");
                }
                else
                {
                    MessageBox.Show("链接数据库失败!请确认服务已开启并输入正确的参数!");
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }