PC Review


Reply
Thread Tools Rate Thread

Creating a Queried DataTable From an Existing DataTable

 
 
Lee Ottaway
Guest
Posts: n/a
 
      22nd Jul 2004
I am manually creating a datatable in memory, creating columns etc for
it and then populating it by importing data from files and various
databases. Once I have the datatable in memory (which consists of
around 10000 records) I need to be able to perform queries on it. I'm
not talking about merely filtering or sorting it which I could do with
a DataView, but performing real queries on it like grouping and
counting.

I can obviously do this by saving the datatable to a database and then
using the OleDbDataAdapter to perform these kind of queries, but I
don't want to have to save the data to a database, firstly because I
don't need to store it and secondly because its incredibly slow saving
10000 records across a network.

Is there a way I can perform SQL queries on a datatable that exists
only in memory?

Thanks


Lee
 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      22nd Jul 2004
Hi Lee,

"Lee Ottaway" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am manually creating a datatable in memory, creating columns etc for
> it and then populating it by importing data from files and various
> databases. Once I have the datatable in memory (which consists of
> around 10000 records) I need to be able to perform queries on it. I'm
> not talking about merely filtering or sorting it which I could do with
> a DataView, but performing real queries on it like grouping and
> counting.
>
> I can obviously do this by saving the datatable to a database and then
> using the OleDbDataAdapter to perform these kind of queries, but I
> don't want to have to save the data to a database, firstly because I
> don't need to store it and secondly because its incredibly slow saving
> 10000 records across a network.
>
> Is there a way I can perform SQL queries on a datatable that exists
> only in memory?


No, there isn't.
You might perform foreach loops (in combination with RowFilter perhaps)
though and check/calculate there.
You might also use DataTable.Select method.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com


 
Reply With Quote
Reply

Thread Tools
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Insert New Row Into Existing DataTable While Looping DataTable Kelvin Microsoft C# .NET 4 8th Dec 2004 09:01 PM
Creating a new Datatable with from an existing Datatable using SQL monkhi Microsoft ADO .NET 1 16th Mar 2004 07:52 PM
Populate a DataTable (with Aggregation) from an existing DataTable =?Utf-8?B?RnJhbmNpc2Nv?= Microsoft ADO .NET 1 21st Feb 2004 11:42 AM
Populate a DataTable (with Aggregation) from an existing DataTable =?Utf-8?B?RGlhYmxv?= Microsoft ADO .NET 1 26th Jan 2004 08:20 PM
Create DataTable From Existing DataTable Gimen Microsoft ADO .NET 5 14th Jan 2004 01:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:28 AM.