Home All Groups Group Topic Archive Search About

How to check datatable.select

Author
18 Jan 2006 12:20 AM
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

Author
18 Jan 2006 12:40 AM
Armin Zingler
Show quote Hide quote
"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
Author
18 Jan 2006 5:47 PM
wk6pack
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

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:OWWqJt8GGHA.1396@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
>
Author
18 Jan 2006 6:09 PM
Armin Zingler
"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
Author
18 Jan 2006 6:49 PM
wk6pack
Hi Armin,

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

Will
Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:etg4vpFHGHA.1288@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
>
Author
18 Jan 2006 8:21 PM
Armin Zingler
"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
Author
18 Jan 2006 9:33 AM
Cor Ligthert [MVP]
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
Author
18 Jan 2006 5:48 PM
wk6pack
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

Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:OFoKtIBHGHA.2440@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
>
>