private void RefreshGrid()
        {
            if (this.InvokeRequired)
            {
                RefreshGridDelegate _displayDataFunc = new RefreshGridDelegate(RefreshGrid);
                this.BeginInvoke(_displayDataFunc);
                return;
            }
            //Write the code to populate the DataGridView control with latest data from the
            //Products table
            string _connstring = "Data Source=localhost/NEWDB;User Id=EDZEHOO;Password=PASS123;";

            try
            {
                OracleConnection _connObj = new OracleConnection(_connstring);
                _connObj.Open();
                OracleCommand _cmdObj = _connObj.CreateCommand();
                _cmdObj.CommandText = "SELECT * FROM Products";
                OracleDataAdapter _adapObj  = new OracleDataAdapter(_cmdObj);
                DataSet           _products = new DataSet();
                _adapObj.Fill(_products);
                dataGridView1.DataSource = _products.Tables[0];
                dataGridView1.Refresh();
                _cmdObj.Dispose();
                _connObj.Close();
                _connObj.Dispose();
                _connObj = null;
                _cmdObj  = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#2
0
 void RefreshGrid()
 {
     if (dgvResult.InvokeRequired)
     {
         RefreshGridDelegate dlg = new RefreshGridDelegate(RefreshGrid);
         this.Invoke(dlg);
     }
     else
     {
         dgvResult.Refresh();
     }
 }
示例#3
0
        private void PopulateGrid(bool ForceRefresh)
        {
            //Show the waiting page.
            SetVisibility(PageToShow.Waiting);

            //Set the async values
            MainWindowValues mwvSetup = LoadMainWindowValues(ForceRefresh);

            System.Windows.Threading.Dispatcher d = this.Dispatcher;

            //Set up a worker
            BackgroundWorker worker = new BackgroundWorker();

            worker.DoWork += delegate(object sender, DoWorkEventArgs e)
            {
                try
                {
                    MainWindowValues mwv = e.Argument as MainWindowValues;

                    if (mwv.ForceRefresh || mwv.DatabaseListingChanged || PrimaryGroup == null || SecondaryGroup == null)
                    {
                        PrimaryGroup   = IndexSet.RetrieveIndexData(mwv.CurrentPrimaryInstanceName, mwv.CurrentPrimaryDatabaseName);
                        SecondaryGroup = IndexSet.RetrieveIndexData(mwv.CurrentSecondaryInstanceName, mwv.CurrentSecondaryDatabaseName);
                        Groups         = IndexGroup.PopulateIndexGroups(PrimaryGroup, SecondaryGroup, mwv.IgnoreMissingTables);
                    }

                    //Now update the display
                    RefreshGridDelegate refresh = new RefreshGridDelegate(RefreshDataGrid);
                    d.BeginInvoke(refresh, mwv, Groups);
                }
                catch (Exception ex)
                {
                    ShowErrorDelegate error = new ShowErrorDelegate(ShowErrorMessage);
                    d.BeginInvoke(error, ex.Message);
                }
            };
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            worker.RunWorkerAsync(mwvSetup);
        }
示例#4
0
 void RefreshGrid()
 {
     if (dgvResult.InvokeRequired)
     {
         RefreshGridDelegate dlg = new RefreshGridDelegate(RefreshGrid);
         this.Invoke(dlg);
     }
     else
         dgvResult.Refresh();
 }