DataSet.Select

  • Thread starter Thread starter Nathan
  • Start date Start date
N

Nathan

Is there any way to do a DataSet.Select() statement and use more than one
selection "query"? For instance, instead of just selecting all rows where
the IDNum is greater than 32 with DataSet.Select("IDNum > 32"), select all
rows where the IDNum > 32 and the Region = Midwest. Is this possible?
 
Nathan,
DataSet does not have a Select method, do you mean DataTable.Select?

The only place I know of where the syntax that expressions in the DataSet OM
is documented is the DataColumn.Expression help topic:

http://msdn.microsoft.com/library/d...fSystemDataDataColumnClassExpressionTopic.asp

There is an AND operator so you can use something like:

Dim table As DataTable
Dim rows() As DataRow
rows = table.Select("IDNum > 32 And Region = 'Midwest')

Hope this helps
Jay
 
Sure, you can use the AND operator:

myDataTable.Select("IDNum > 32 AND Region = "MidWest")



More info:

http://tinyurl.com/2cvqh

Concatenation is allowed using Boolean AND, OR, and NOT operators. You can
use parentheses to group clauses and force precedence. The AND operator has
precedence over other operators. For example:

(LastName = 'Smith' OR LastName = 'Jones') AND FirstName = 'John'


--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
Hi Jan,

Jan Tielens said:
Sure, you can use the AND operator:

myDataTable.Select("IDNum > 32 AND Region = "MidWest")

Forgot singe parenthesis? :)
.... Region = 'MidWest'")
 
Nathan said:
Is there any way to do a DataSet.Select() statement and use more than
one selection "query"? For instance, instead of just selecting all
rows where the IDNum is greater than 32 with DataSet.Select("IDNum >
32"), select all rows where the IDNum > 32 and the Region = Midwest.
Is this possible?

You mean Datatable.select? Yes, you can use the And operator. See the help
for System.Data.DataColumn.Expression explaining the syntax.
 
Miha Markic said:
Hi Jan,



Forgot singe parenthesis? :)

I believe the correct response was "single quote marks". The judges would
have also accepted apostrophe... yes.. apostrophe. =)

again... my 2 useless cents.
 
Cor,
Doh! I see my sample had a typo also...

Odd that both samples had small typos... It must of been the phase of the
moon, yea that's it ;-)

Jay
 
Hi,

CJ Taylor said:
I believe the correct response was "single quote marks". The judges would
have also accepted apostrophe... yes.. apostrophe. =)

Ouch. I'll had to improve my english ;-)
 
Back
Top