dcsimg
Results 1 to 4 of 4
  1. #1

    Thread Starter
    New Member
    Join Date
    May 2018
    Posts
    2

    How to get a cloumns value if you have a variable object as Paramter for name?

    sValiue and ctl are objects, Get_MFieldName returns an object.

    sValue = DS.Tables(Table).Rows(Row)(Get_mFieldName(ctl))

    Error
    Overload resolution failed because no Public 'Item' is most specific for these arguments:
    'Public Property Item(columnIndex As Integer) As System.Object':
    Not most specific.
    'Public Property Item(columnName As String) As System.Object':
    Not most specific.
    'Public Property Item(column As System.Data.DataColumn) As System.Object':
    Not most specific.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,682

    Re: How to get a cloumns value if you have a variable object as Paramter for name?

    The error message is telling you exactly what the problem is. The Item property, which is the default property and thus invoked when you simply index a DataRow object, expects an Integer, a String or a DataRow. You said yourself that Get_mFieldName returns an Object, which is none of those three things.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2018
    Posts
    2

    Re: How to get a cloumns value if you have a variable object as Paramter for name?

    Thanks this is working with all String values.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    98,682

    Re: How to get a cloumns value if you have a variable object as Paramter for name?

    If you're saying, without actually saying, that you changed the declaration of Get_mFieldName to return a String instead of an Object then that makes sense. The name of something is always going to be text so it doesn't make sense for a method specifically intended to get a name to return anything other than a String. The compiler then knows that you specifically intend to invoke the Item property overload that expects a String contain the name of the column whose value you want.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.