Solved

Updating a DataTable in Memory?

Posted on 2009-04-13
1
275 Views
Last Modified: 2012-06-27
Experts,

All the lit I've read on updating a bound DataTable talk about mapping the "UpdateMethod" property to a method that will take parameters from the grid and then updating the actual database table.  In other words, the update goes right to the table instead of to the DataTable object.  I don't want to write to the database when the user is adding quantities to items in his/her order.  I want to update in memory and then once the user is finished, update that object to a database.

Is this possible?
0
Comment
Question by:NigelRocks
1 Comment
 
LVL 18

Accepted Solution

by:
philipjonathan earned 500 total points
Comment Utility
Yes. First, you need to get the DataRow to be updated. For this you need to have some kind of key or identification. An example:
DataRow[] rows = dtTable.Select("ID = 10");
DataRow rowToUpdate = null;
if ((rows != null) && (rows.Count > 0))
  rowToUpdate = rows[0];

OR, if you have initialised the PrimaryKey property of that DataTable:

DataRow rowToUpdate = dtTable.Rows.Find(10);

Second, update the columns accordingly:
rowToUpdate["GivenName"] = "John";
rowToUpdate["FamilyName"] = "Doe";
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now