Differentiating between types of Datasources (Finding a Classes Base Class)

Denaes

Senior Contributor
Joined
Jun 10, 2003
Messages
956
Okay, Datasource is an Object, which allows it to handle multiple types of DataSources.

I'm having a user pass one in, I was "DirectCast"ing it to a DataSet, which is what I need, which worked fine if I choose A Dataset or TypedDataSet as the Datasource.

If I choose a BindingSource, it errors out here. Obviously you can't DirectCast a BindingSource into a DataSet.

But because things are Typed, I can't see how to make any logical statements to handle the DirectCasting.

If I getType, it returns the TypedClass (ie CustomerDataSet rather than DataSet; or CustomerBindingSource rather than BindingSource).

Is there any way to get to that base class?

I need to be able to tell "Is this a Dataset?" "Is this a BindingSource?" so I can handle that DirectCast and the different methods to get into a specified tables data.
 
Shoulda asked a while ago. Always seems I find an answer like 5 minutes after I ask on a forum.

Visual Basic:
If TypeOf (m_BindingSource.DataSource) Is DataSet Then
                Dim ds As DataSet = DirectCast(m_BindingSource.DataSource, DataSet)
                PopulateDataTable(ds)
End If

Well the If...Then statement is the answer to the problem, but I figured I'd throw that out there in case this helps anyone else :D
 
Back
Top