Ejemplo n.º 1
0
 public StoreUpgrader(BaseDBConnection connection)
 {
     this._connection = connection;
 }
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (this._connection != null) 
            {
                this._connection.Disconnect();
                this.btnDisconnect.Enabled = false;
                this.ShowDatabaseInformation();
            }

            try {
                switch (this.cboDBFormat.SelectedIndex)
                {
                    case 0:
                        //Microsoft SQL Server
                        this._connection = new MicrosoftSQLServerConnection(this.txtDBServer.Text, this.txtDBName.Text, this.txtUsername.Text, this.txtPassword.Text);
                        break;

                    case 1:
                        //MySQL Server
                        if (this.txtPort.Text.Equals(String.Empty))
                        {
                            //No Port specified
                            this._connection = new MySQLServerConnection(this.txtDBServer.Text, this.txtDBName.Text, this.txtUsername.Text, this.txtPassword.Text);
                        }
                        else
                        {
                            int port;
                            if (Int32.TryParse(this.txtPort.Text, out port))
                            {
                                //A Port was Specified
                                this._connection = new MySQLServerConnection(this.txtDBServer.Text, port, this.txtDBName.Text, this.txtUsername.Text, this.txtPassword.Text);
                            }
                            else
                            {
                                //Invalid Port Specified
                                this._connection = new MySQLServerConnection(this.txtDBServer.Text, this.txtDBName.Text, this.txtUsername.Text, this.txtPassword.Text);
                            }
                        } 
                        break;

                    case 2:
                        //Virtuoso Universal Server (Virtual Database)
                        MessageBox.Show("Virtuoso Universal Server (Virtual Database) not yet supported in this Tool");
                        this._connection = null;
                        break;
                    case 3:
                        //Microsoft Access
                        MessageBox.Show("Microsoft Access not yet supported in this Tool");
                        this._connection = null;
                        break;
                    default:
                        MessageBox.Show("Unknown Database Format selected");
                        this._connection = null;
                        break;
                }

                if (this._connection != null)
                {
                    this._connection.Connect();
                    this.btnDisconnect.Enabled = true;
                    this.btnConnect.Enabled = false;
                }
                else
                {
                    this.btnDisconnect.Enabled = false;
                    this.btnConnect.Enabled = true;
                }
                this.ShowDatabaseInformation();
            } 
            catch (Exception ex) 
            {
                MessageBox.Show("Error connecting to the specified Database:\n" + ex.Message, "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
 public StoreCompacter(BaseDBConnection connection, bool fullCompact)
 {
     this._connection = connection;
     this._fullCompact = fullCompact;
 }