Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            TstServer   = txtbServer.Text;
            TstPort     = txtbPort.Text;
            TstUserName = txtbUsername.Text;
            TstPassword = txtbPassword.Text;
            TstDatabase = txtbDatabase.Text;


            try
            {
                ConnectDB.con.ConnectionString = "Server = '" + TstServer + "';  " + "Port = '" + TstPort + "'; " + "Database = '" + TstDatabase + "'; " + "user id = '" + TstUserName + "'; " + "password = '******'";

                ConnectDB.con.Open();
                ConnectDB.MySQLServer   = txtbServer.Text;
                ConnectDB.MySQLPort     = txtbPort.Text;
                ConnectDB.MySQLUserName = txtbUsername.Text;
                ConnectDB.PwdMySQL      = txtbPassword.Text;
                ConnectDB.DBNameMySQL   = txtbDatabase.Text;

                ConnectDB.SaveData();
                this.Close();

                Interaction.MsgBox("Test connection successful", MsgBoxStyle.Information, "Database Settings");
            }
            catch
            {
                Interaction.MsgBox("The system failed to establish a connection", MsgBoxStyle.Information, "Database Settings");
            }
            ConnectDB.DisconnMy();
        }