Solved

Updating rows in memory DataTable

Posted on 2003-10-24
3
402 Views
Last Modified: 2010-04-16
Hi,

I'm interesting if its posible to update row of DataTable with new data.

I'm creating table:

DataTable OutTable=new DataTable("IndexTicker");
.
.
.
After I insert rows in table I want to update every 10 secound data
in table with new index data. Primary colomn is IndexCode.

Any idea?

Thanks
Tomaz
0
Comment
Question by:tomazsr
  • 2
3 Comments
 
LVL 6

Expert Comment

by:zrh
Comment Utility
Is this an ASP.NET application, or a Windows Forms application.
The direction to go depends greatly on which of these your writing for.

ZRH
0
 
LVL 1

Author Comment

by:tomazsr
Comment Utility
Windows form application that use Web Services and I want that
requery on web services (lasts 3-5 secound) run in separate thread.

Tomaz
0
 
LVL 6

Accepted Solution

by:
zrh earned 250 total points
Comment Utility
Try using the System.Timers.Timer component.
Set the Interval to be 6 seconds to make update ~10 seconds (9 to 11sec.)
Handle the Timer.Elapsed event.
In the method handling the Timer.Elapsed event, query the webservice, get the data.
Find the row using:
DataRow[] rows = OutTable.Select("IndexCode = " + IndexCodeOfRowToUpdate);
if(rows.Length == 1) { // If one row match found
    DataRow r = (DataRow)rows.GetValue(0);
    r["columnName"] = webServiceDataForColumnName;
    ...
    ...
}

NOTE: This would only allow updating of one row (one selected in datagrid maybe?) every ten seconds,
          did you want to update each row on its own 10sec interval starting from when added? (little more complicated)

I think this is what you want.
ZRH
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

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

8 Experts available now in Live!

Get 1:1 Help Now