Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > .NET

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 10-28-2009, 11:18 AM
jcb1269 jcb1269 is offline
Registered User
 
Join Date: Jul 2004
Posts: 296
Question Adding rows to datatable.

Ok,

I'm having trouble here and not sure what I'm doing wrong. I'm looping through one table and updating rows in another table. When I do the following code:

dt.Rows.Add(dr)
dt.AcceptChanges()

When I view the records in the dt table, the new record is not there?!? Does AcceptChanges() not apply the data to the table?

Any help would be greatly appreciated, any links to help would be greatly appreciated.

Thank.

jb
Reply With Quote
  #2  
Old 11-02-2009, 06:28 PM
JBourgeois JBourgeois is offline
Registered User
 
Join Date: Feb 2004
Location: Longueuil, Québec
Posts: 110
AcceptChanges does not save the data, it simply marks the DataTable as being synchronized with the data in the database, which in fact prevents any updating to the database table. Most examples you see in textbooks use AcceptChanges without reason, so many programmers tend to use it without knowing what it does.

What you are looking for is the Update method.

dt.Rows.Add(dr)
dt.Update
__________________
Jacques Bourgeois
JBFI
http://www3.sympatico.ca/jbfi/homeus.htm
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
editing Rows of the gridview, which is bounded with DataTable ani.since1982 ASP.NET 1 12-19-2007 10:11 AM
Creating an unbound datagrid ninel ASP.NET 2 08-10-2007 04:06 AM
adding rows to a grid DTC Valerie Anover .NET 0 02-10-2002 07:48 PM
Adding rows to Web based Data Grids Christian .NET 3 02-09-2002 12:10 AM
Adding New Rows Tim Manos VB Classic 3 08-27-2001 02:20 PM


All times are GMT -4. The time now is 09:37 PM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.