Accessing data on the fly

G

Guest

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



.....
 
M

Marina

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.
 
G

Guest

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 said:
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 said:
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



....
 
M

Marina

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 said:
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 said:
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 said:
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



....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top