Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Datareader using column names. Surely there's a better way

Datareader using column names. Surely there's a better way

Scheduled Pinned Locked Moved ASP.NET
sharepointdatabasequestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sam Heller
    wrote on last edited by
    #1

    Hey I'm retrieving datat using a datareader as follows If Not IsDBNull(dr("ClientID")) Then ClientLink.HRef = Page.ResolveUrl("~/secure_code/clients/ViewClient.aspx") + "?ClientID=" + dr.GetInt32(1).ToString() End If But i would prefer to use the column name instead of it's index as I use the SP in various places and would like the flexibility to alter it how ever I feel I want to without anything breaking. ISDBnull allows you to just type in the column name as a string but all of the get methods don't. All I could work out was this. If Not IsDBNull(dr("ClientID")) Then ClientLink.HRef = Page.ResolveUrl("~/secure_code/clients/ViewClient.aspx") + "?ClientID=" + dr.GetInt32(dr.GetOrdinal("ClientID")).ToString() End If Is there a better way???

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups