PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Accessing data on the fly
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Accessing data on the fly
![]() |
Accessing data on the fly |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi All,
I am creating a DataTable on the fly and populate it in the code for example like: DataTable dT = new DataTable(); dT.Columns.Add("col1"); dT.Columns.Add("col2"); DataRow dR = dT.NewRow(); dR["col1"] = "val1"; dR["col2"] = "val2"; Is there anyway to run a select statement against this table? For example like: select * from dT order by col1? What will be the connection object? Thanks, Moheb ..... |
|
|
|
#2 |
|
Guest
Posts: n/a
|
No, there is not.
The best you can do is put a dataview on top of the datatable and specify a filter and a sort. A datatable is not an in memory database. Very important to remember that. "Moheb" <Moheb@discussions.microsoft.com> wrote in message news:6FBF2738-C1D1-4F04-BE4B-AC2D97E3B69D@microsoft.com... > Hi All, > > I am creating a DataTable on the fly and populate it in the code for > example > like: > > DataTable dT = new DataTable(); > dT.Columns.Add("col1"); > dT.Columns.Add("col2"); > DataRow dR = dT.NewRow(); > dR["col1"] = "val1"; > dR["col2"] = "val2"; > > Is there anyway to run a select statement against this table? For example > like: > > select * from dT order by col1? > > What will be the connection object? > > Thanks, > > Moheb > > > > .... > > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
You can't run a select statement, but you can pass an expression to the
DataTable.Select method. See: http://msdn.microsoft.com/library/d...-us/cpref/html/ frlrfsystemdatadatatableclassselecttopic.asp Andrew Conrad Microsoft Corp http://blogs.msdn.com/aconrad/ |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Thx for the reply. Actually it depends on what you mean by memory. An
automatic variable of type DataTable is a piece of memory on the stack. It'd be nice if you could run a select query on it (more than just sort and filter expressions, for example like count, sum, etc.) just like you are running one on "hard" object pieces such as sql tables. For the problem I am working on I have to mimic this by extra coding whereas I should have been able write a single line of code containing a select statement. Hopefully in the next release of adonet by MS! Regards, Moheb "Marina" wrote: > No, there is not. > > The best you can do is put a dataview on top of the datatable and specify a > filter and a sort. > > A datatable is not an in memory database. Very important to remember that. > > "Moheb" <Moheb@discussions.microsoft.com> wrote in message > news:6FBF2738-C1D1-4F04-BE4B-AC2D97E3B69D@microsoft.com... > > Hi All, > > > > I am creating a DataTable on the fly and populate it in the code for > > example > > like: > > > > DataTable dT = new DataTable(); > > dT.Columns.Add("col1"); > > dT.Columns.Add("col2"); > > DataRow dR = dT.NewRow(); > > dR["col1"] = "val1"; > > dR["col2"] = "val2"; > > > > Is there anyway to run a select statement against this table? For example > > like: > > > > select * from dT order by col1? > > > > What will be the connection object? > > > > Thanks, > > > > Moheb > > > > > > > > .... > > > > > > > > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
I mean memory on the stack, when i say memory.
I think it is easy to overlook the complexity in writing a query parser and execution engine. This would typically include indexing, query rewriting, optimizing, etc. This is what Oracle, SQL Server, etc, are for. So again, I don't think you will see an in memory database, as it would involve .NET basically containing SQL Server that could run in an app. "Moheb" <Moheb@discussions.microsoft.com> wrote in message news 35DCF12-B9BE-40AA-BBDF-BF3727E07879@microsoft.com...> Thx for the reply. Actually it depends on what you mean by memory. An > automatic variable of type DataTable is a piece of memory on the stack. > It'd > be nice if you could run a select query on it (more than just sort and > filter > expressions, for example like count, sum, etc.) just like you are running > one > on "hard" object pieces such as sql tables. For the problem I am working > on I > have to mimic this by extra coding whereas I should have been able write a > single line of code containing a select statement. Hopefully in the next > release of adonet by MS! > > Regards, > > Moheb > > "Marina" wrote: > >> No, there is not. >> >> The best you can do is put a dataview on top of the datatable and specify >> a >> filter and a sort. >> >> A datatable is not an in memory database. Very important to remember >> that. >> >> "Moheb" <Moheb@discussions.microsoft.com> wrote in message >> news:6FBF2738-C1D1-4F04-BE4B-AC2D97E3B69D@microsoft.com... >> > Hi All, >> > >> > I am creating a DataTable on the fly and populate it in the code for >> > example >> > like: >> > >> > DataTable dT = new DataTable(); >> > dT.Columns.Add("col1"); >> > dT.Columns.Add("col2"); >> > DataRow dR = dT.NewRow(); >> > dR["col1"] = "val1"; >> > dR["col2"] = "val2"; >> > >> > Is there anyway to run a select statement against this table? For >> > example >> > like: >> > >> > select * from dT order by col1? >> > >> > What will be the connection object? >> > >> > Thanks, >> > >> > Moheb >> > >> > >> > >> > .... >> > >> > >> > >> >> >> |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

35DCF12-B9BE-40AA-BBDF-BF3727E07879@microsoft.com...
