A better way to refer to DB columns?

  • Thread starter Thread starter Darrel
  • Start date Start date
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
 
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!
 
ds.Tables(0).Rows(rowCount)("ColumnName")

Dammit. It's that simple?

I feel dumb now. ;o)

Thanks! ;o)

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

Tom Dacon
Dacon Software Consulting
 
Back
Top