SQLDataReader

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dom

    SQLDataReader

    In the old days, using ADO, I used to be able to move up and down in a
    resultset, but using functions like MoveNext, MoveFirst, MoveLast,
    MovePrev. I don't see any of that in the SQLDataReader object. It
    seems I can only move through it sequentially. Is that true?

    Dom
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: SQLDataReader

    Dom,

    Yes, that is true. The SqlDataReader (or any class that derives from
    DbDataReader, really) is meant for forward-only, read-only access.

    If you want to move through a set of data, then you will need to load
    the data into a DataTable, through a DbDataAdapter derivative (in this case,
    SqlDataAdapter) and then you can cycle through the rows in any way that you
    wish.

    Mind you that doing it in this way is going to be the equivalent of
    setting the cursor location on an ADODB Recordset to adUseClient, and then
    loading the data statically (adOpenStatic). Basically, the DataTable is an
    in-memory representation of the result set.

    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Dom" <dolivastro@gma il.comwrote in message
    news:21bddab3-f67f-40f1-b025-2be8833d858f@e1 0g2000prf.googl egroups.com...
    In the old days, using ADO, I used to be able to move up and down in a
    resultset, but using functions like MoveNext, MoveFirst, MoveLast,
    MovePrev. I don't see any of that in the SQLDataReader object. It
    seems I can only move through it sequentially. Is that true?
    >
    Dom

    Comment

    • Dom

      #3
      Re: SQLDataReader

      Thanks for clarifying this. BTW, you've answered so many of my
      questions, I feel like you're my private tutor.

      Dom



      On Dec 11, 1:28 pm, "Nicholas Paldino [.NET/C# MVP]"
      <m...@spam.guar d.caspershouse. comwrote:
      Dom,
      >
      Yes, that is true. The SqlDataReader (or any class that derives from
      DbDataReader, really) is meant for forward-only, read-only access.
      >
      If you want to move through a set of data, then you will need to load
      the data into a DataTable, through a DbDataAdapter derivative (in this case,
      SqlDataAdapter) and then you can cycle through the rows in any way that you
      wish.
      >
      Mind you that doing it in this way is going to be the equivalent of
      setting the cursor location on an ADODB Recordset to adUseClient, and then
      loading the data statically (adOpenStatic). Basically, the DataTable is an
      in-memory representation of the result set.
      >
      --
      - Nicholas Paldino [.NET/C# MVP]
      - m...@spam.guard .caspershouse.c om
      >
      "Dom" <dolivas...@gma il.comwrote in message
      >
      news:21bddab3-f67f-40f1-b025-2be8833d858f@e1 0g2000prf.googl egroups.com...
      >
      >
      >
      In the old days, using ADO, I used to be able to move up and down in a
      resultset, but using functions like MoveNext, MoveFirst, MoveLast,
      MovePrev. I don't see any of that in the SQLDataReader object. It
      seems I can only move through it sequentially. Is that true?
      >
      Dom- Hide quoted text -
      >
      - Show quoted text -

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: SQLDataReader

        Can I send you a bill? =) J/K


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Dom" <dolivastro@gma il.comwrote in message
        news:7d0dfdf0-7d13-48ee-9c04-d40492337ed7@t1 g2000pra.google groups.com...
        Thanks for clarifying this. BTW, you've answered so many of my
        questions, I feel like you're my private tutor.
        >
        Dom
        >
        >
        >
        On Dec 11, 1:28 pm, "Nicholas Paldino [.NET/C# MVP]"
        <m...@spam.guar d.caspershouse. comwrote:
        >Dom,
        >>
        > Yes, that is true. The SqlDataReader (or any class that derives from
        >DbDataReader , really) is meant for forward-only, read-only access.
        >>
        > If you want to move through a set of data, then you will need to load
        >the data into a DataTable, through a DbDataAdapter derivative (in this
        >case,
        >SqlDataAdapter ) and then you can cycle through the rows in any way that
        >you
        >wish.
        >>
        > Mind you that doing it in this way is going to be the equivalent of
        >setting the cursor location on an ADODB Recordset to adUseClient, and
        >then
        >loading the data statically (adOpenStatic). Basically, the DataTable is
        >an
        >in-memory representation of the result set.
        >>
        >--
        > - Nicholas Paldino [.NET/C# MVP]
        > - m...@spam.guard .caspershouse.c om
        >>
        >"Dom" <dolivas...@gma il.comwrote in message
        >>
        >news:21bddab 3-f67f-40f1-b025-2be8833d858f@e1 0g2000prf.googl egroups.com...
        >>
        >>
        >>
        In the old days, using ADO, I used to be able to move up and down in a
        resultset, but using functions like MoveNext, MoveFirst, MoveLast,
        MovePrev. I don't see any of that in the SQLDataReader object. It
        seems I can only move through it sequentially. Is that true?
        >>
        Dom- Hide quoted text -
        >>
        >- Show quoted text -
        >

        Comment

        Working...