Jump to content
Xtreme .Net Talk

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


Recommended Posts

Posted

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.

Posted

Shoulda asked a while ago. Always seems I find an answer like 5 minutes after I ask on a forum.

 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...