By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,711 Members | 2,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,711 IT Pros & Developers. It's quick & easy.

Running Select query against dataTable

P: n/a
VMI
How can I run a Select query from a datatable so that it only brings the
fields I want? For example, if my datatable has 30 fields, a query would be
"select custId, Name" because those are the only two fields I need. Then I'd
like to put the result in another datatable.

Thanks.
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
VMI,

You can't perform selects in that manner from a DataTable. The best you
can do is call the Select method, and pass a filter based on column values
(the documentation for the Select method will tell you how you can construct
a filter). Once you do that, you can take the rows returned, and copy only
the columns you want from each row to a new data table.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"VMI" <vo******@yahoo.com> wrote in message
news:Om****************@tk2msftngp13.phx.gbl...
How can I run a Select query from a datatable so that it only brings the
fields I want? For example, if my datatable has 30 fields, a query would
be "select custId, Name" because those are the only two fields I need.
Then I'd like to put the result in another datatable.

Thanks.

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.