InvalidCastException when subclassing datatable

davearia

Well-known member
Joined
Jan 4, 2005
Messages
184
Hi,

At work we have a data access layer that has been developed by one of developers. Things is it works well enough with the exception of one thing.

There is a class in this datalayer that subclasses System.Data.Datatable. So for example if I populated a System.Data.Dataset and then tried to put the first table of this dataset into this class like so:
Code:
Dim dt as new myDatable
dt = ds.Tables(0)
I get an InvalidCastException. I have created the most basic of classes for myDatable.
Code:
Public Class myDatable: Inherits System.Data.DataTable
    
End Class

Is there as interface missing or something?
 
Ds.Tables(0) is a datatable. What your saying is what I expected.

Thanks for confirming this, I just wanted to know if the table in the dataset could be cast to a subclass of datatable.

Just so long as I know.

Cheers, Dave.
 
Back
Top