Example #1
0
        public string Display(object obj, BackgroundWorker worker, DoWorkEventArgs eArgs)
        {
            string result = null;
            bool bConnexion = true;
            if (this.connexion == null || this.connexion.Cnn == null || this.connexion.Cnn.State.ToString() == "Closed")
            {
                connexion = new Connexion.Connexion("Oracle");
                bConnexion = connexion.Open();
            }
            if (bConnexion)
            {
                result = DisplayQueryData(connexion, Convert.ToString(obj), dgv, worker, eArgs);
            }

            return result;
        }
Example #2
0
        private void toolStripButtonDeleteCol_Click(object sender, EventArgs e)
        {
            if (
                MessageBox.Show(
                    string.Format("Are you sure you want to drop the column {0} from the table {1} ?",
                                  dataGridViewOracleFields.CurrentRow.Cells["cname"].Value, CurrentTablename),
                    "Drop column", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                string sql =
                    string.Format("ALTER TABLE {0} DROP COLUMN {1}", CurrentTablename,
                                  dataGridViewOracleFields.CurrentRow.Cells["cname"].Value);

                try
                {
                    if (this.connexion == null || this.connexion.Cnn == null ||
                        this.connexion.Cnn.State.ToString() == "Closed")
                    {
                        connexion = new Connexion.Connexion("Oracle");
                        connexion.Open();
                    }
                    if (connexion.IsOpen)
                    {
                        using (DbCommand cmd = connexion.Cnn.CreateCommand())
                        {
                            cmd.CommandText = sql;
                            cmd.Prepare();
                            //int colno = 0;
                            int result = cmd.ExecuteNonQuery();
                            getTable();
                        }
                    }
                }
                catch (Exception ex)
                {
                    string errorMessage = ex.Message;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        errorMessage += "\n" + ex.Message;
                    }
                    MessageBox.Show(errorMessage, "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #3
0
        private void buttonSelectTarget_Click(object sender, EventArgs e)
        {
            FormConnection formConnection = new FormConnection();
            //formConnection.MdiParent = this.ParentForm;
            if (formConnection.ShowDialog() == DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(formConnection.textBoxOracleUserId.Text)
                    && !string.IsNullOrEmpty(formConnection.textBoxOraclePassword.Text)
                    && !string.IsNullOrEmpty(formConnection.TNSNamesComboBox.Text))
                {
                    Config.SaveLastConnectionInfo(formConnection.textBoxOracleUserId.Text,
                                           formConnection.textBoxOraclePassword.Text,
                                           formConnection.TNSNamesComboBox.Text);

                    labelTargetTnsnames.Text = string.Format("Source {0}@{1}", formConnection.textBoxOracleUserId.Text, formConnection.TNSNamesComboBox.Text);
                    TargetConnexion = new Connexion.Connexion("Oracle");
                    // Open connexions
                    TargetConnexion.Open(formConnection.textBoxOracleUserId.Text,
                                         formConnection.textBoxOraclePassword.Text, formConnection.TNSNamesComboBox.Text);
                    TargetConnexion.Close();
                }
            }
        }
Example #4
0
        private void toolStripButtonAddCol_Click(object sender, EventArgs e)
        {
            FormAddCol frmAddCol = new FormAddCol();
            frmAddCol.labelTablename.Text = CurrentTablename;
            frmAddCol.Tablename = CurrentTablename;
            if (frmAddCol.ShowDialog() == DialogResult.OK)
            {
                // Create the column
                string sql = frmAddCol.textBoxSql.Text;

                try
                {
                    if (this.connexion == null || this.connexion.Cnn == null ||
                        this.connexion.Cnn.State.ToString() == "Closed")
                    {
                        connexion = new Connexion.Connexion("Oracle");
                        connexion.Open();
                    }
                    if (connexion.IsOpen)
                    {
                        using (DbCommand cmd = connexion.Cnn.CreateCommand())
                        {
                            cmd.CommandText = sql;
                            cmd.Prepare();
                            //int colno = 0;
                            int result = cmd.ExecuteNonQuery();
                            getTable();
                        }
                    }
                }
                catch (Exception ex)
                {
                    string errorMessage = ex.Message;
                    while (ex.InnerException != null)
                    {
                        ex = ex.InnerException;
                        errorMessage += "\n" + ex.Message;
                    }
                    MessageBox.Show(errorMessage, "Unexpected error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            frmAddCol.Close();
            frmAddCol.Dispose();
        }
Example #5
0
        private void buttonSelectSource_Click(object sender, EventArgs e)
        {
            FormConnection formConnection = new FormConnection();
            //formConnection.MdiParent = this.ParentForm;
            if (formConnection.ShowDialog() == DialogResult.OK)
            {
                if (!string.IsNullOrEmpty(formConnection.textBoxOracleUserId.Text)
                    && !string.IsNullOrEmpty(formConnection.textBoxOraclePassword.Text)
                    && !string.IsNullOrEmpty(formConnection.TNSNamesComboBox.Text))
                {
                    labelSourceTnsnames.Text = string.Format("Source {0}@{1}", formConnection.textBoxOracleUserId.Text, formConnection.TNSNamesComboBox.Text);
                    SourceConnexion = new Connexion.Connexion("Oracle");
                    // Open connexions
                    SourceConnexion.Open(formConnection.textBoxOracleUserId.Text, formConnection.textBoxOraclePassword.Text, formConnection.TNSNamesComboBox.Text);
                    // Get Tables of source connexion
                    if (SourceConnexion.Cnn.State.ToString() != "Closed")
                    {
                        using (DbCommand cmd = SourceConnexion.Cnn.CreateCommand())
                        {
                            string SQL = "select distinct table_name  " +
                                         "  from user_tables " +
                                         " order by table_name ";

                            cmd.CommandText = SQL;
                            cmd.Prepare();

                            using (DbDataReader rd = cmd.ExecuteReader())
                            {
                                while (rd.Read())
                                {
                                    SourceTablesCheckedListBox.Items.Add(rd.GetValue(0), false);
                                }
                            }
                        }
                    }
                    // close connexions
                    SourceConnexion.Close();
                }
            }
        }