Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataAdapter filling a DataTable with different number of records
 

DataAdapter filling a DataTable with different number of records

Hey!

I have a function in which a dataAdapter fills a dataset from a stored procedure. The dataset tables have their primary keys set. This function is called repetitively every few seconds. The number of records returned from the stored proceduremay change based on certain conditions and parameters. The dataSet is bound to a dataGrid in the UI

My problem goes as follows; assuming the first callto the SPreturned 10 records, which are now loaded in the dataTable, and then the second call returned only 8 records, thedatatable will update those 8 recordsbut willNOT remove the extra 2. They will stay in the dataTable.I need to figure a way to make sure that the data in the dataTable exactly reflects what is returned from the SP.

Clearing the dataTable is not an option, for this will cause the datagrid bound to this datatable to flicker every few seconds.

I tried changing the rowState of the extra records in the dataTable to "deleted", and it worked! But the problem here is that marking them as "deleted" will not remove them from the dataTable, and I need to keep the dataTable as small as possible (for performance reasons).

Any ideas?
Thanks

Krimboss  Monday, January 22, 2007 10:42 PM
Krimboss wrote:

I tried changing the rowState of the extra records in the dataTable to "deleted", and it worked! But the problem here is that marking them as "deleted" will not remove them from the dataTable, and I need to keep the dataTable as small as possible (for performance reasons).

You said you changed the rowState of the extra records in the dataTable, i.e. you know which rows are extra, why not use row.delete() methodto removetheseextra records?

Zhi-Xin Ye  Thursday, January 25, 2007 6:15 AM
Krimboss wrote:

I tried changing the rowState of the extra records in the dataTable to "deleted", and it worked! But the problem here is that marking them as "deleted" will not remove them from the dataTable, and I need to keep the dataTable as small as possible (for performance reasons).

You said you changed the rowState of the extra records in the dataTable, i.e. you know which rows are extra, why not use row.delete() methodto removetheseextra records?

Zhi-Xin Ye  Thursday, January 25, 2007 6:15 AM

You can use google to search for other answers

Custom Search

More Threads

• DataGridView
• Please Delete this thread
• Number the rows in the Datagrid
• How to set BindingSource of a detail BindingNavigator in a master-detail relation ?
• DataGridView Formatting Question
• is the dataset copied to the memory
• How to Insert New Row in DataTable
• Slow work of cell selection in DataGridView
• Sample Code for: DatagridViewColumnComboTreeView
• Adding databinding to a datagridview cell