Windows Develop Bookmark and Share   
 index > Windows Forms General > DataGridView Refresh (no prior solutions work)
 

DataGridView Refresh (no prior solutions work)

All,

Preface: I really appreciate the help. I know questions similar have been asked many times because I've seen them in these forums and all over Google. No solution works.

Problem: When adding entries (rows) to a database, the DataGridView that is bound to the dataset connected to that database does not refresh.

Description: I essentially have bound my DataGridView to an MS Access file containing the table personnel. When I use the provided adapter to insert a row in the database, no matter what I do, the DataGridView does not refresh. As you can see in the compiling code below, I have tried several things.

Code:

Form1::PersonnelTableAdapter->Insert(theSSN, theLast, theFirst, theHourly, theHours); //this line does add an entry to the MS Access database

Form1::datasetPersonnel->Tables[0]->BeginLoadData();

System::Data::DataTableReader ^ refreshReader = Form1::datasetPersonnel->Tables[0]->CreateDataReader();

Form1::datasetPersonnel->Tables[0]->Load(refreshReader);

Form1::dataGridViewPersonnel->EndEdit();

Form1::dataGridViewPersonnel->Refresh();

Form1::dataGridViewPersonnel->Parent->Refresh();

Form1::datasetPersonnel->GetChanges();

Form1::personnelBindingSource->ResetBindings(true);

Form1::dataGridViewPersonnel->Refresh();

Thanks - I've tried everything I can find and nothing works,

Ryan

RG6  Tuesday, March 07, 2006 10:24 PM

Solution Found!

Hopefully anybody else that has this very basic problem does not have to spend the hours I spent. Simply use this line:

this->theDataAdapter->Fill(this->dataset->tableName);

Hope that helps somebody. Let me know if I can help more.

Ryan

RG6  Wednesday, March 08, 2006 12:45 AM

Solution Found!

Hopefully anybody else that has this very basic problem does not have to spend the hours I spent. Simply use this line:

this->theDataAdapter->Fill(this->dataset->tableName);

Hope that helps somebody. Let me know if I can help more.

Ryan

RG6  Wednesday, March 08, 2006 12:45 AM

You can use google to search for other answers

Custom Search

More Threads

• datagridview
• How to trap ESC key in DateTimePicker's drop down calendar?
• webbrowser used as file browser opens each folder in another windows
• Environment.SpecialFolder Enumeration
• Any help to create 'Today Is' Calendar Control ??
• Strong naming an assembly not working...please help
• Clipboard and a File
• Label Text Color
• ListView and StatusBar
• Scrolling the Menu