View Single Post
  #16 (permalink)  
Old May 12th, 2004, 03:00 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

I don't know why the code doesn't work with a more complex DataSet. Right now, I can't see any reason why it would do so. I also don't know why the problem doesn't occur with a simple DataSet. Need to test this someday....

With the "nonworking code", are you referring to this:

If v_cboSearch.Items.Item(intPos) = v_strValue Then

It makes sense you get an error about the conversion. The Items.Item(intPos) is not Numeric, but refers to a DataRowView object located at position intPos. That is, the Item property (or the Items indexer in C#) returns an object of the underlying datatype, which happens to be a DataRowView in this case.

So, this would have worked:

If CType(v_cboSearch.Items.Item(intPos), DataRowView).Item("FirstName") = v_strValue Then

(assuming FirstName is the item you bound your data to).

Does this clarify things?

Maybe a complex DataSet exposes different information. Maybe when there is only one table, it knows exactly what is is dealing with and can expose default properties. Maybe with a complex DataSet, you need to set some properties explicitly yourself. Like I said, I'll test this someday and see if I can make any sense out of it.


Imar Spaanjaars
Everyone is unique, except for me.
The Following User Says Thank You to Imar For This Useful Post:
Ron Howerton (February 22nd, 2013)