Exemplo n.º 1
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            TstServerMySQL   = txtServerHost.Text;
            TstPortMySQL     = txtPort.Text;
            TstUserNameMySQL = txtUserName.Text;
            TstPwdMySQL      = txtPassword.Text;
            TstDBNameMySQL   = txtDatabase.Text;

            try
            {
                SQLConn.conn.ConnectionString = "Server = '" + TstServerMySQL + "';  " + "Port = '" + TstPortMySQL + "'; " + "Database = '" + TstDBNameMySQL + "'; " + "user id = '" + TstUserNameMySQL + "'; " + "password = '******'";
                SQLConn.conn.Open();

                SQLConn.DBNameMySQL   = txtDatabase.Text;
                SQLConn.ServerMySQL   = txtServerHost.Text;
                SQLConn.UserNameMySQL = txtUserName.Text;
                SQLConn.PortMySQL     = txtPort.Text;
                SQLConn.PwdMySQL      = txtPassword.Text;

                SQLConn.SaveData();
                this.Close();
            }
            catch
            {
                Interaction.MsgBox("The system failed to establish a connection", MsgBoxStyle.Information, "Database Settings");
            }
            SQLConn.DisconnMy();
            //save database
        }
Exemplo n.º 2
0
        private void cmdTest_Click(object sender, EventArgs e)
        {
            //Test database connection

            TstServerMySQL   = txtServerHost.Text;
            TstPortMySQL     = txtPort.Text;
            TstUserNameMySQL = txtUserName.Text;
            TstPwdMySQL      = txtPassword.Text;
            TstDBNameMySQL   = txtDatabase.Text;


            try
            {
                SQLConn.conn.ConnectionString = "Server = '" + TstServerMySQL + "';  " + "Port = '" + TstPortMySQL + "'; " + "Database = '" + TstDBNameMySQL + "'; " + "user id = '" + TstUserNameMySQL + "'; " + "password = '******'";


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