Lightweight Table Access (ADO.NET)

  • Thread starter Thread starter Guinness Mann
  • Start date Start date
G

Guinness Mann

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
 
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[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.public.dotnet.datatools
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: Guinness Mann <[email protected]>
| Newsgroups: microsoft.public.dotnet.general
| Subject: Lightweight Table Access (ADO.NET)
| Date: Mon, 29 Sep 2003 11:37:29 -0700
| Organization: Dublin Brewery
| Lines: 20
| Message-ID: <[email protected]>
| NNTP-Posting-Host: p-029.newsdawg.com
| X-Newsreader: MicroPlanet Gravity v2.60
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!skynet.be!skynet.be!skynet.be!skynet.be!feed1.news.be.easynet.net!news.
moat.net!news-out.newsfeeds.com!propagator2-maxim!news-in-maxim.spamkiller.n
et!news.he.net!cyclone-sf.pbi.net!129.250.175.17!pln-w!spln!dex!extra.newsgu
y.com!newsp.newsguy.com!enews4
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:110275
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| 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
|
|
 
Back
Top