Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Updating a DataTable in Memory?

Posted on 2009-04-13
1
Medium Priority
?
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 18

Accepted Solution

by:
philipjonathan earned 2000 total points
ID: 24134516
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 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