Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Apr 2005
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Retrieving Value from DataColumn (VB.net)

    Hello All!!

    Can't figure out for the life of me how to get the value from a DataColumn and throw it in a label. I've tried about every variation I can think of, and no dice. I know the DataSet/DataTable was populated correctly, and I know the name of the column I want is "JDESC"

    Here's the code:


    lblJobName.Text = ds.Tables("MASTER_JCM_R1").Rows[0].(Item("JDESC").Value)

    I've also tried:

    ds.Tables("MASTER_JCM_R1").Columns("JDESC").Value
    ds.Tables("MASTER_JCM_R1").Columns("JDESC").ToStri ng()
    ds.Tables("MASTER_JCM_R1").Rows[0].Item("JDESC").ToString()

    ...a few others as well. ALL generate the error:

    Value of type 'System.Data.DataRowCollection' cannot be converted to 'String'

    Help! Thanks so much!

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Retrieving Value from DataColumn (VB.net)

    Try this:

    lblJobName.Text = ds.Tables("MASTER_JCM_R1").Rows(0).Item("JDESC").V alue.ToString()
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Apr 2005
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Retrieving Value from DataColumn (VB.net)

    Charlotte,

    Thank you! You're advice gave me the little jump I needed to get her jammin'! In the end, I removed the Value and so the final line looks like this:

    lblJobName.Text = ds.Tables("MASTER_JCM_R1").Rows(0).Item("JDESC").T oString()

    You're the best! Thanks so much!

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Retrieving Value from DataColumn (VB.net)

    I still have trouble remembering when you need Value and when you don't, so I'm glad you figured it out. The rest is very standard syntax for .Net. <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •