-
May 16th, 2018, 07:33 AM
#1
Thread Starter
Member
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.
-
May 16th, 2018, 08:41 AM
#2
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.
-
May 16th, 2018, 10:50 AM
#3
Thread Starter
Member
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.
-
May 16th, 2018, 08:38 PM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|