public OracleView(OracleDBConnection connection)
 {
     InitializeComponent();
     this.dbConnection = connection;
     this.dbConnection.createConnection();
     InitializeRefresh();
 }
        public OracleSessionDetails(OracleDBConnection connection)
        {
            InitializeComponent();
            this.dbConnection = connection;
            OracleConnection databaseConnection = dbConnection.getDatabaseConnection();
            String query;
            OracleCommand command = new OracleCommand("DBMS_SESSION.set_identifier",databaseConnection);
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(dbConnection.getUsername(), OracleDbType.Char);
            command.ExecuteNonQuery();

            query = "SELECT SYS_CONTEXT('userenv', 'SID') AS SID, "
                    + "SYS_CONTEXT('userenv', 'HOST') AS HOST, "
                    + "USER AS username "
                    + "FROM dual";
            command = new OracleCommand(query, databaseConnection);
            OracleDataReader reader;
            command.CommandText = query;
            command.CommandType = CommandType.Text;
            reader = command.ExecuteReader();

            while (reader.Read())
            {
                this.sessionListing.Rows.Add("SID", reader["SID"]);
                this.sessionListing.Rows.Add("HOST", reader["HOST"]);
                this.sessionListing.Rows.Add("DATABASE", dbConnection.getDatabaseConnection().DataSource);
                this.sessionListing.Rows.Add("USER", reader["USERNAME"]);
            }
            reader.Close();
        }
        public OracleDll(OracleDBConnection connection, String objectType, String objectName)
        {
            InitializeComponent();
            this.dbConnection = connection;
            DataTable data = new DataTable();
            OracleConnection databaseConnection = connection.getDatabaseConnection();
            String query = "SELECT DBMS_METADATA.GET_DDL('" + objectType + "',"
                + "'" + objectName +"')AS DDL FROM DUAL";
            Console.WriteLine(query);
            OracleCommand command = new OracleCommand(query, databaseConnection);
            OracleDataReader reader;
            command.CommandText = query;
            command.CommandType = CommandType.Text;
            reader = command.ExecuteReader();

            data.Load(reader);

            foreach (DataRow row in data.Rows)
            {
                String ColumnData = row[0].ToString();
                this.richTextBox1.AppendText(ColumnData);
            }

            reader.Close();
        }
        private void ConnectionButton_Click(object sender, EventArgs e)
        {
            if (this.ConnectionDetails1.Text == "Server Name")
            {
                SQLServerConnection databaseConnection = new SQLServerConnection(this.ConnectionDetailsText1.Text,
                    this.ConnectionDetailsText2.Text, this.ConnectionDetailsText3.Text, this.ConnectionDetailsText4.Text);
                String result = databaseConnection.createConnection();
                MessageBox.Show(result);
                SqlConnection dbConnection = databaseConnection.getDatabaseConnection();
                if (result == "Connection Established. Press OK to continue.")
                {
                    new SQLServerView(databaseConnection).Show();
                    this.Dispose();
                }

            }
            else
            {
                OracleDBConnection databaseConnection = new OracleDBConnection(this.ConnectionDetailsText1.Text,
                    this.ConnectionDetailsText2.Text, this.ConnectionDetailsText4.Text);
                String result = databaseConnection.createConnection();
                MessageBox.Show(result);
                if (result == "Connection Established. Press OK to continue.")
                {
                    new OracleView(databaseConnection).Show();
                    this.Dispose();
                }
            }
        }
 public TableViewerOracle(String tableName, OracleDBConnection connection, bool option)
 {
     InitializeComponent();
     this.dbConnection = connection;
     this.tableName = tableName;
     if (option)
     {
         this.TableOptions.TabPages.Remove(TableAddColumn);
         this.partitionNumber.Dispose();
         this.tablePartitions.Dispose();
     }
     else
     {
         partitions();
     }
     refreshInitializeTable();
 }
        public OracleTableSpaceData(OracleDBConnection connection)
        {
            InitializeComponent();
            this.dbConnection = connection;
            OracleConnection databaseConnection = connection.getDatabaseConnection();
            String query = "SELECT ts.TABLESPACE_NAME, "
                                + "TO_CHAR(SUM(NVL(fs.bytes, 0)) / 1024 / 1024, '99,999,990.99') AS MB_FREE "
                                + "FROM "
                                + "USER_FREE_SPACE fs, "
                                + "USER_TABLESPACES ts, "
                                + "USER_USERS us "
                                + "WHERE fs.TABLESPACE_NAME(+) = ts.TABLESPACE_NAME "
                                + "GROUP BY ts.tablespace_name";

            OracleCommand command = new OracleCommand(query, databaseConnection);
            OracleDataReader reader;
            DataTable data = new DataTable();
            command.CommandText = query;
            command.CommandType = CommandType.Text;
            reader = command.ExecuteReader();
            data.Load(reader);
            this.tableSpaceData.DataSource = data;
            reader.Close();
        }
        public OracleIndexes(OracleDBConnection connection, String indexName)
        {
            InitializeComponent();
            this.dbConnection = connection;
            OracleConnection databaseConnection = connection.getDatabaseConnection();
            String query = "SELECT INDEX_NAME, INDEX_TYPE, USER_INDEXES.TABLE_NAME, UNIQUENESS "
                           + "FROM USER_INDEXES, USER_TABLES "
                           + "WHERE INDEX_NAME = '" + indexName + "' "
                           + "AND USER_INDEXES.TABLE_NAME = USER_TABLES.TABLE_NAME";
            OracleCommand command = new OracleCommand(query, databaseConnection);
            OracleDataReader reader;
            command.CommandText = query;
            command.CommandType = CommandType.Text;
            reader = command.ExecuteReader();

            while (reader.Read())
            {
                this.indexList.Rows.Add("NAME", reader["INDEX_NAME"]);
                this.indexList.Rows.Add("TYPE", reader["INDEX_TYPE"]);
                this.indexList.Rows.Add("TABLE", reader["TABLE_NAME"]);
                this.indexList.Rows.Add("UNIQUENESS", reader["UNIQUENESS"]);
            }
            reader.Close();
        }