Home All Groups Group Topic Archive Search About

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

Author
31 Jan 2006 1:43 AM
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.

Author
31 Jan 2006 6:26 AM
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.


Show quoteHide quote
"Optimus" <sarun***@gmail.com> wrote in message
news:1138671817.339470.204330@o13g2000cwo.googlegroups.com...
> 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.
>