question about query datatable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I would like to query a datatable in C#. The query is like

select sum(quantity)
from table
where company="IBM"

And I would get this number and display it in my GUI.
Is there a way to do it?
Thanks

Chrisben
 
To further clarify my question, the datatable is a datatable object I created
in C#. It is the datasource for my DataGrid. I do NOT need to query sql
server database, instead, I need to do the same thing on the table created in
the C#. thanks
 
You use the DataTable.Select method or DataTable.Compute method
to perform queries against a DataTable.

Decimal val = dt.Compute("Sum(quantity)","company='IBM'");
 

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

Back
Top