A better way to refer to DB columns?

D

Darrel

Right now, I'm pulling data from a db, attaching it to a ds, then navigating
the ds to build HTML to spit out to the page. My calls to the individual
columns are like this:

ds.Tables(0).Rows(rowCount).Item(1).ToString)

This works but as I change things, it gets a bit akward to have to keep
going back to count the number of items to match the item(x) call.

Is there a way to call these columns by name rather than by count?

-Darrel
 
S

Scott Mitchell [MVP]

Darrel said:
Right now, I'm pulling data from a db, attaching it to a ds, then navigating
the ds to build HTML to spit out to the page. My calls to the individual
columns are like this:

ds.Tables(0).Rows(rowCount).Item(1).ToString)

This works but as I change things, it gets a bit akward to have to keep
going back to count the number of items to match the item(x) call.

Is there a way to call these columns by name rather than by count?

Sure:

ds.Tables(0).Rows(rowCount)("ColumnName")

Happy Programming!



--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
D

Darrel

ds.Tables(0).Rows(rowCount)("ColumnName")

Dammit. It's that simple?

I feel dumb now. ;o)

Thanks! ;o)

-Darrel
 
T

Tom Dacon

It gets even better than Scott's response. Look into typed datasets.

Tom Dacon
Dacon Software Consulting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top