Re: DataTable

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Wal Turner (vooose_at_hotmail.com)
Date: 10/19/04


Date: Wed, 20 Oct 2004 08:49:36 +1000

Thank you for your reply. Unfortunately I cannot give a specific example as
the bug seems to occur randomly. The select statement (or WHERE clause) is a
simple filter, eg "TradeID=" + x

which works as expected most of the time. I guess the unusual thing here is
that dataTable.Select( ) is returning a null row - I've read the
documentation for DataTable and it would seem by definition if its returning
a row then that row can't be null!

I guess the (sql) analogy here is doing a select statement and having
count(*) = 1 but then when you actually get the row in question it doesnt
exist!

Regards

Wal

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:OMwsBAetEHA.1216@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> > I am using the System.Data.DataTable class which I have heard may
display
> > some unusual behaviour.
>
> Like?
>
> > I am doing
> >
> > DataRow[] dr = dataTable.Select(sql);
> >
> > The sql in this instance doesnt matter -
>
> In general it DOES , the sql is not a SELECT clause from sql, but a
filter
> expression ( like the WHERE clause in SQL )
>
> > what is important is that dr.Length
> > is greater than 0, implying there is at least one result.
> > However I discovered that sometimes this method was returning dr.Length
=
> 1
> > when I thought it should return 0 rows. In fact, the dataTable contents
> > reflected it returning 0 rows but it chose to return one anyway!
> >
> > Further inspection showed this DataRow to be null, ie dr[0] == null
> >
> > Has anyone come across this similar problem?
>
> Nop, please try to post a complete example where this happen, if possible
> with the table definition, etc it may be a bug after all.
>
>
> cheers,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
>
>



Relevant Pages

  • Re: [Info-Ingres] unexpected Ambiguous Replace
    ... FROM clause, and no aggregates in the SQL. ... have incontrovertible proof of a bug and you could progress it accordingly. ...
    (comp.databases.ingres)
  • Re: DataTable
    ... > some unusual behaviour. ... > The sql in this instance doesnt matter - ... In general it DOES, the sql is not a SELECT clause from sql, but a filter ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SQL Query Help
    ... I can confirm this behavior and it looks like a bug. ... It's not a bug, it's SQL. ... Sum() returns a row with a null value if no rows satisfies the where clause. ...
    (comp.databases.paradox)
  • Re: Better "Join" vs "Where" clause?
    ... running the SQL directly, in the SQL Server tools, rather than ... WHERE clause has been deprecated, ... AFAIK one cannot perform an outer join in Access without using the explicit ...
    (microsoft.public.access.queries)
  • Thanks
    ... Thanks for "With" clause, ... Why are you formatting data in the back end? ... how to use custom column heading in where clause ... This only works on SQL 2005. ...
    (microsoft.public.sqlserver.programming)