How to check datatable.select

  • Thread starter Thread starter wk6pack
  • Start date Start date
W

wk6pack

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
 
wk6pack said:
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
 
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
 
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
 
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
 
wk6pack said:
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
 
Hi Armin,

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

Will
Armin Zingler said:
wk6pack said:
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
 
wk6pack said:
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
 
Back
Top