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

How to check datatable.select

P: n/a
Hi,

How do I check datatable.select(filter) in the following:

for each dtrow in datatable.select(filter)
....
next

I've also tried:

if not (datatable.select(filter) is nothing) then
for each dtrow in datable.select(filter)
.....
next
end if
but it gets an exception in my catch.

I get an error when the select doesnt find any rows to return. How can I
chech for this or is there a property to use?
Basically, if the select doesnt find any rows, then I want to do something
else.

thanks,
Will
Jan 18 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi,

How do I check datatable.select(filter) in the following:

for each dtrow in datatable.select(filter)
...
next

I've also tried:

if not (datatable.select(filter) is nothing) then
for each dtrow in datable.select(filter)
.....
next
end if
but it gets an exception in my catch.

I get an error when the select doesnt find any rows to return. How
can I chech for this or is there a property to use?
Basically, if the select doesnt find any rows, then I want to do
something else.

Check the length property of the array returned. If it's 0, no rows have
been returned.
Armin

Jan 18 '06 #2

P: n/a
WK6Pack,

Are you sure that your table exist?
\\\
Dim dt As DataTable
If Not dt Is Nothing Then
If Not dt.Select() Is Nothing Then
For Each dr As DataRow In dt.Select()
Next
End If
End If
///
This runs for me although that it does nothing of course.

I hope this helps,

Cor
Jan 18 '06 #3

P: n/a
Hi,

The table exists with records there. If you select on the filter without
finding a record in the datatable, it will error out.

thanks,
Will

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:OF**************@TK2MSFTNGP14.phx.gbl...
WK6Pack,

Are you sure that your table exist?
\\\
Dim dt As DataTable
If Not dt Is Nothing Then
If Not dt.Select() Is Nothing Then
For Each dr As DataRow In dt.Select()
Next
End If
End If
///
This runs for me although that it does nothing of course.

I hope this helps,

Cor

Jan 18 '06 #4

P: n/a
Hi,

There are records in the datatable but not on the filter. Datatable.rows.
ie. datatable has records a1, a2 but I want to see if a3 is in there.

datatable.select("col1='ad3') will error out with Error: can't find column
[a3]. I want to prevent this.

I'm not sure what you mean check the array length? I dont see that method
on the datatable.

thanks,
Will

"Armin Zingler" <az*******@freenet.de> wrote in message
news:OW**************@TK2MSFTNGP11.phx.gbl...
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi,

How do I check datatable.select(filter) in the following:

for each dtrow in datatable.select(filter)
...
next

I've also tried:

if not (datatable.select(filter) is nothing) then
for each dtrow in datable.select(filter)
.....
next
end if
but it gets an exception in my catch.

I get an error when the select doesnt find any rows to return. How
can I chech for this or is there a property to use?
Basically, if the select doesnt find any rows, then I want to do
something else.

Check the length property of the array returned. If it's 0, no rows have
been returned.
Armin

Jan 18 '06 #5

P: n/a
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi,

There are records in the datatable but not on the filter.
Datatable.rows. ie. datatable has records a1, a2 but I want to see
if a3 is in there.

datatable.select("col1='ad3') will error out with Error: can't find
column [a3]. I want to prevent this.
In this example, you use the column name "Col1", thus I don't understand how
it can not find column "a3". What are the available column names, what are
the values in these columns and what is the value you are searching for?
I'm not sure what you mean check the array length? I dont see that
method on the datatable.


I wrote, "of the array returned". I meant the array that is returned from
the Select method.
Armin

Jan 18 '06 #6

P: n/a
Hi Armin,

The column, col1 exists but the value in col1 is not found. so it returns
the error.

Will
"Armin Zingler" <az*******@freenet.de> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi,

There are records in the datatable but not on the filter.
Datatable.rows. ie. datatable has records a1, a2 but I want to see
if a3 is in there.

datatable.select("col1='ad3') will error out with Error: can't find
column [a3]. I want to prevent this.
In this example, you use the column name "Col1", thus I don't understand

how it can not find column "a3". What are the available column names, what are
the values in these columns and what is the value you are searching for?
I'm not sure what you mean check the array length? I dont see that
method on the datatable.


I wrote, "of the array returned". I meant the array that is returned from
the Select method.
Armin

Jan 18 '06 #7

P: n/a
"wk6pack" <wk***@sd61.bc.ca> schrieb
Hi Armin,

The column, col1 exists but the value in col1 is not found. so it
returns the error.


If it doesn't find a row, it does not return this error. If it does, there
must be something wrong elsewhere to which I don't have insight.

Can you reproduce the problem in a new project? If you can, you can send it
to me (zipped please; insert an underscore between "no" and "spam" in my
email address)
Armin

Jan 18 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.