Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to save data from dataTable

Status
Not open for further replies.

nguyentaiuyenchi

Technical User
Nov 5, 2001
39
VN
Hi all,
I built dataTable by fill method. That mean, the data is disconnected with datasource. After that, I perform add new, update, delete rows..... Please show me the way to save to datasource?

Thank in advance.


Uyen Chi
Software developer
 
... and after that, how to refresh this table? I dispose of this table and reload but it seem no work.

Cheers,

Uyen Chi
Software developer
 
Hi,
Use SqlDataAdapter , SqlCommand, SqlCommand objects to fill a DataSet or a DataTables objects.
To commit the changes into the source table , use myDataAdapter.Update(DataTable). This functiopn returns the number of afected rows and it is doing the job.
If you intent to reuse the DataTable object you no need to reload it if the Update was successful. In this case do not dispose the DataTable object but use AcceptChanges() on the DataTable object and the DataTable object is ready to register other updates.

George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top