A better way to refer to DB columns?

Discussion in 'ASP .Net' started by Darrel, Oct 29, 2004.

  1. Darrel

    Darrel Guest

    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, Oct 29, 2004
    #1
    1. Advertising

  2. 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.4GuysFromRolla.com

    * When you think ASP.NET, think 4GuysFromRolla.com!
     
    Scott Mitchell [MVP], Oct 29, 2004
    #2
    1. Advertising

  3. Darrel

    Darrel Guest

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

    Dammit. It's that simple?

    I feel dumb now. ;o)

    Thanks! ;o)

    -Darrel
     
    Darrel, Oct 29, 2004
    #3
  4. Darrel

    Tom Dacon Guest

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

    Tom Dacon
    Dacon Software Consulting

    "Darrel" <> wrote in message
    news:...
    > 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
    >
    >
    >
     
    Tom Dacon, Oct 29, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MK
    Replies:
    1
    Views:
    841
    Peter Hansen
    Jun 25, 2003
  2. Web Search Store
    Replies:
    11
    Views:
    479
    Web Search Store
    Apr 23, 2008
  3. Andy B
    Replies:
    7
    Views:
    362
    Damien
    May 30, 2008
  4. Replies:
    1
    Views:
    105
  5. Replies:
    2
    Views:
    56
    Mark H Harris
    May 13, 2014
Loading...

Share This Page