Can't cast one identical typed ds to another

  • Thread starter Thread starter Eric Sabine
  • Start date Start date
E

Eric Sabine

In a project I have a VB windows app and a web service. The application is
being designed to run whether or not the user can access the web service, it
it can't, it will be in "disconnected" mode. I have created a typed dataset
in the windows app and copied it exactly to the service under another name.
In the app, the client instantiates the typed dataset of both the web
service and the local win app.

Friend connectedDs As MyApp.Windows.Services.appDataSet
Friend disconnectedDs As MyApp.Windows.discDataSet

While these datasets are identical in elements and element structures (3
tables in each), they of course have different names. In one method, the
client app should connect to the webservice, get the returned dataset
(connectedDs in my case) and then copy the data to the disconnectedDs.
Then, the existance of the connectedDs isn't import and will shortly
thereafter be killed. No updates ever get passed back to the webservice.

My problem exists at the copy. No matter how I try to copy, I get the
"specific cast is not valid" exception. (BTW Option Strict is ON).

Here's basically the line.
disconnectedDs = connectedDs.Copy
or
disconnectedDs = CType(connectedDs.Copy, MyApp.Windows.discDataSet)

Any hints on what I'm doing wrong?
Eric
 
Eric Sabine said:
In a project I have a VB windows app and a web service. The application is
being designed to run whether or not the user can access the web service, it
it can't, it will be in "disconnected" mode. I have created a typed dataset
in the windows app and copied it exactly to the service under another name.
In the app, the client instantiates the typed dataset of both the web
service and the local win app.

Friend connectedDs As MyApp.Windows.Services.appDataSet
Friend disconnectedDs As MyApp.Windows.discDataSet

While these datasets are identical in elements and element structures (3
tables in each), they of course have different names. In one method, the
client app should connect to the webservice, get the returned dataset
(connectedDs in my case) and then copy the data to the disconnectedDs.
Then, the existance of the connectedDs isn't import and will shortly
thereafter be killed. No updates ever get passed back to the webservice.

My problem exists at the copy. No matter how I try to copy, I get the
"specific cast is not valid" exception. (BTW Option Strict is ON).

Here's basically the line.
disconnectedDs = connectedDs.Copy
or
disconnectedDs = CType(connectedDs.Copy, MyApp.Windows.discDataSet)

Any hints on what I'm doing wrong?
Eric

The datasets are different types, so you can't convert or cast.
You must merge instead. DataSet.Merge will move the data from one to
another.

David
 
I have run into the same problems with a webservice client, I ended up going
with untyped datasets at both ends, and now it works perfectly... I just
have to specify the Item property of any value I need, instead of having an
enumeration of the columns in the IDE intellisense... isn't too bad - I do
wish that typed datasets could easily be cast using CType([],"")

Severin
 
Thanks Severin, I never posted why I'm using typed datasets. This
application is using crystal reports for .net and the datasouce for the
reports has to be a dataset (at least for this project).

Thanks
Eric

Severin said:
I have run into the same problems with a webservice client, I ended up going
with untyped datasets at both ends, and now it works perfectly... I just
have to specify the Item property of any value I need, instead of having an
enumeration of the columns in the IDE intellisense... isn't too bad - I do
wish that typed datasets could easily be cast using CType([],"")

Severin



Eric Sabine said:
In a project I have a VB windows app and a web service. The application is
being designed to run whether or not the user can access the web
service,
it
it can't, it will be in "disconnected" mode. I have created a typed dataset
in the windows app and copied it exactly to the service under another name.
In the app, the client instantiates the typed dataset of both the web
service and the local win app.

Friend connectedDs As MyApp.Windows.Services.appDataSet
Friend disconnectedDs As MyApp.Windows.discDataSet

While these datasets are identical in elements and element structures (3
tables in each), they of course have different names. In one method, the
client app should connect to the webservice, get the returned dataset
(connectedDs in my case) and then copy the data to the disconnectedDs.
Then, the existance of the connectedDs isn't import and will shortly
thereafter be killed. No updates ever get passed back to the webservice.

My problem exists at the copy. No matter how I try to copy, I get the
"specific cast is not valid" exception. (BTW Option Strict is ON).

Here's basically the line.
disconnectedDs = connectedDs.Copy
or
disconnectedDs = CType(connectedDs.Copy, MyApp.Windows.discDataSet)

Any hints on what I'm doing wrong?
Eric
 
Back
Top