Lightweight Table Access (ADO.NET)

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

    #1

    Lightweight Table Access (ADO.NET)

    Greetings,

    I'm working in VS2003.NET using C#.

    I need to download a few rows from an SQL Server database table and then
    be able to page back and forth through them. I don't need to make any
    changes nor post any updates.

    In the past I've downloaded the rows using a datareader, copied the
    fields for each row into a structure and then added the structure to an
    arrayList.

    That works ok, but I was wondering about populating a datatable instead.
    Looking at a datatable, though I don't see any getNext(), getPrev(), etc
    functions, so I don't see what that would buy me.

    Any thoughts?

    -- Rick

  • Stephen Provine [MSFT]

    #2
    RE: Lightweight Table Access (ADO.NET)

    Hi Rick,

    If you use a data table, each row is accessible by index (just like an
    array list). There is no concept of "current" index, however, so you would
    need to keep track of this yourself. Once you have this, implementing a
    getNext or getPrev method is fairly simple (increment or decrement the
    current index value).

    The syntax for doing this on a data table is:

    dataTable.Rows[i][columnName]

    where i is the index and columnName is the name of a column in that row.

    If you use this mechanism, you can avoid having to manually read the data
    in from the data reader and define your own structure to contain the row
    data. However, you may find that the data reader implementation is more
    efficient than building a whole data table for it.

    Hope this helps,
    VSData Team
    Please post to our newsgroup: microsoft.publi c.dotnet.datato ols
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    | From: Guinness Mann <GMann@dublin.c om>
    | Newsgroups: microsoft.publi c.dotnet.genera l
    | Subject: Lightweight Table Access (ADO.NET)
    | Date: Mon, 29 Sep 2003 11:37:29 -0700
    | Organization: Dublin Brewery
    | Lines: 20
    | Message-ID: <MPG.19e229d3ed 0004ed9896c8@ne ws.newsguy.com>
    | NNTP-Posting-Host: p-029.newsdawg.co m
    | X-Newsreader: MicroPlanet Gravity v2.60
    | Path:
    cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-onlin
    e.de!skynet.be! skynet.be!skyne t.be!skynet.be! feed1.news.be.e asynet.net!news .
    moat.net!news-out.newsfeeds.c om!propagator2-maxim!news-in-maxim.spamkille r.n
    et!news.he.net! cyclone-sf.pbi.net!129. 250.175.17!pln-w!spln!dex!extr a.newsgu
    y.com!newsp.new sguy.com!enews4
    | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.genera l:110275
    | X-Tomcat-NG: microsoft.publi c.dotnet.genera l
    |
    | Greetings,
    |
    | I'm working in VS2003.NET using C#.
    |
    | I need to download a few rows from an SQL Server database table and then
    | be able to page back and forth through them. I don't need to make any
    | changes nor post any updates.
    |
    | In the past I've downloaded the rows using a datareader, copied the
    | fields for each row into a structure and then added the structure to an
    | arrayList.
    |
    | That works ok, but I was wondering about populating a datatable instead.
    | Looking at a datatable, though I don't see any getNext(), getPrev(), etc
    | functions, so I don't see what that would buy me.
    |
    | Any thoughts?
    |
    | -- Rick
    |
    |

    Comment

    Working...