Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > A better way to refer to DB columns?

Reply
Thread Tools

A better way to refer to DB columns?

 
 
Darrel
Guest
Posts: n/a
 
      10-29-2004
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



 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      10-29-2004
Darrel wrote:
> 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
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
Reply With Quote
 
 
 
 
Darrel
Guest
Posts: n/a
 
      10-29-2004
> ds.Tables(0).Rows(rowCount)("ColumnName")

Dammit. It's that simple?

I feel dumb now. ;o)

Thanks! ;o)

-Darrel


 
Reply With Quote
 
Tom Dacon
Guest
Posts: n/a
 
      10-29-2004
It gets even better than Scott's response. Look into typed datasets.

Tom Dacon
Dacon Software Consulting

"Darrel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Portable way to refer to the null device? Roy Smith Python 1 02-07-2009 11:56 PM
A way to refer to items in Session object without using Session directly Andy B ASP .Net 7 05-30-2008 10:49 AM
is there a way to refer to public properties in other user controls Web Search Store ASP .Net 11 04-23-2008 07:00 PM
Build a Better Blair (like Build a Better Bush, only better) Kenny Computer Support 0 05-06-2005 04:50 AM
Platform-independent way to refer to execute path MK Python 1 06-25-2003 05:43 PM



Advertisments