Results 1 to 7 of 7

Thread: Datareader.HasRows not supported ?

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    55

    Datareader.HasRows not supported ?

    How come the Datareader.Hasrows function doesnt work unless you set Its contents Scrollable how do i read through the datareader effectively ?

    I've been using Datareader.read = false if its empty and after that read one record.
    How do i check if there's more then one record in it and go through it ?

    Ive tried , While Datareader.read
    or Do while Datareader.read
    but it ends without reading anything , while i know it has something.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Datareader.HasRows not supported ?

    I can't look anything up, but I always use a loop for datareaders:

    Do while DataReader.Read


    (at least I'm pretty sure I do).

    Since that is what you are doing, then it sure looks like there is something else going wrong. You say that you know there is something there, but every test you are trying seems to indicate that there actually isn't. How do you know that there is something?

    How about running the same query as ExecuteScalar, and see whether you get something back. It sure seems like the DataReader part is not the problem.
    My usual boring signature: Nothing

  3. #3
    Fanatic Member Strider's Avatar
    Join Date
    Sep 2004
    Location
    Dublin, Ireland
    Posts
    612

    Re: Datareader.HasRows not supported ?

    i always use for multiple items

    While l_datareader.Reader
    'do whatever
    End WHile

    and for a single item return
    If l_datareader.Read

    End If
    Barry


    Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
    .NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0

    SQL Server 2005/2000/SQL Server CE 2.0


    If you like, rate this post

    Compact Framework for Beginners

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Datareader.HasRows not supported ?

    Still should have worked. The loop ending without reading anything strongly suggests that the reader is empty.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    55

    Re: Datareader.HasRows not supported ?

    The funny thing is that datareader.executeresultset Does give me 2 or 3 items.
    and i have to set the resulsetoptions.scrollable , its very strange.

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Datareader.HasRows not supported ?

    That is strange. I have never had that problem, nor have I ever used ExecuteResultSet, but that sure makes me suspicious. I have no access to much of anything at the moment, and won't until tomorrow, but that method makes me think that you are creating the datareader in a way that is different from what I am expecting.
    My usual boring signature: Nothing

  7. #7

    Thread Starter
    Member
    Join Date
    Mar 2007
    Posts
    55

    Re: Datareader.HasRows not supported ?

    the Do while datareader.read works now, but with executeresultset though

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width