Mike D12995

I populate a DataSet Table using the DataAdapter.

Then the query changes and I need to repopulate the DS.Table[MyTableName]

I am getting extra rows. It keeps adding to the existing rows. I have tried DS.Tables[myTable].Clear and DS.Tables[myTable].Reset

What am I doing wrong

Thanks,

Mike



Re: .NET Framework Data Access and Storage ReUsing a Data Set Table - Getting the wrong row count

alihijazi

Before you call the Fill method of your dataadapter, clear the rows of your datatable,

ds.Tables["table_name"].Rows.Clear()





Re: .NET Framework Data Access and Storage ReUsing a Data Set Table - Getting the wrong row count

VMazur

You also could reinitialize your DataTable/DataSet variable to release all the resources associated with it.




Re: .NET Framework Data Access and Storage ReUsing a Data Set Table - Getting the wrong row count

Mike D

I tried this and same results with row count=12 when it should be 2

Thanks

Mike





Re: .NET Framework Data Access and Storage ReUsing a Data Set Table - Getting the wrong row count

Mike D

Vmazure

I cannot reset this at this point as it is in a inner loop when the parameter may change for the query.

The only thing I can see to do is deleting the rows in the DS and accept changes.

Any other Ideas

Thank you

Mike





Re: .NET Framework Data Access and Storage ReUsing a Data Set Table - Getting the wrong row count

VMazur

I believe you would need to post the post the code. Otherwise it is hard to see what could cause this issue




Re: .NET Framework Data Access and Storage ReUsing a Data Set Table - Getting the wrong row count

Erick Thompson - MSFT

Try using the DataTable.Rows.Clear() method. This should remove all the rows in the DataTable. If you want to "reset" your DataTable, you should also call AcceptChanges.

Erick Thompson