Query datatable using SQL

  • Thread starter Thread starter Marty
  • Start date Start date
M

Marty

I have a DataSet with a DataTable that I created from a text file.
Now I would like to run querys against the table using SQL. Something
like:
SELECT tblTemp.col1, tblTemp.col2, tblTemp.col3
FROM tblTemp
WHERE (((tblTemp.col1) Like "*A") AND ((tblTemp.col3) Like "*e"));
Is this possible without saving to a database? My searches are turning
up nothing.
 
Marty,

It isn't possible to perform this operation on the DataTable. You might
be able to get away with this using a DataView, and setting the RowFilter
property to a filter (I believe that it supports LIKE).

Hope this helps.
 
You cannot get a different set of columns, but you can get a filter set
of rows using the DataTable.Select method.

DataTable myTable = .....
DataRow[] rows = myTable.Selelct(@"((tblTemp.col1) Like ""*A"") AND
((tblTemp.col3) Like ""*e"")");
 
Back
Top