Unable to cast object of type 'System.Data.DataSet' to Typed DataSet

O

Optimus

Hi everyone,

I currently develop an application in vs.net 2005 with vb.net.
I was trying to use typed dataset and I've got in trouble for
converting untyped dataset
into Typed DataSet. I don't know why I cannot perform this casting
operation properly.
First off, I've got my Typed DataSet named "AuthInfo" declared and I
then created an instance of that class. What I'd like to do next is to
perform querying through the method ExecuteDataSet() of Microsoft Data
Access Library which will return me the untyped dataset. Here is the
point, I would like to convert the return untyped DataSet into my Typed
DataSet "AuthInfo" but I'm still getting this error "Unable to cast
object of type 'System.Data.DataSet' to type 'AuthInfo'. ..." I've put
my code snippet here as shown below.

Dim doAuth as AuthInfo
dst = db.ExecuteDataSet(dbCommand)
doAuth = CType(dst, AuthInfo)

I think I've seen someone do something like this before but I've got no
idea what's wrong with my code.
 
C

CMM

The generic dataset returned cannot be "Cast" because it doesn't inherit or
derived from your Typed Dataset.

Look into the "Merge" method of the typed dataset to read-in data from the
generic untyped dataset. If the tables and columns match it should pour the
data into the appropriate corresponding places in your typed dataset.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top