By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,414 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.

Jan 31 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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.
"Optimus" <sa******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.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.

Jan 31 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.