PC Review


Reply
Thread Tools Rate Thread

Convert regular DataSet to strongly typed DataSet

 
 
moondaddy
Guest
Posts: n/a
 
      17th Apr 2004
Is there a way to convert a regular dataset to a strongly typed dataset?
I'm receiving a dataset from a webservice and when it was created on the
server, it was created as a strongly typed dataset. However, the return
type of the webservice is just Dataset because they can not return strongly
typed datasets (as far as I know...). Now back on the client, I want to use
this dataset as a strongly typed one. I get a cast exception if I do
something like this

dim ds as dsCustomer = CType(MyWebServiceCall(CustID),dsCustomer).

Even though this line doesn't work, it shows you what I want to do. Any
good ideas?

--
(E-Mail Removed)


 
Reply With Quote
 
 
 
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      17th Apr 2004
Hi moondaddy,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to cast an untyped DataSet
returned from web service to a typed one. If there is any misunderstanding,
please feel free to let me know.

We cannot cast an untyped DataSet to a typed one directly. However, as far
as I know, we can return a typed DataSet from a web method. If you are
referencing a web service in your project, the proxy will create the
definition of the typed DataSet automatically for you. So you can create
strong typed DataSet object directly from the client machine.

If you are returning a typed DataSet named MyDataSet, you can achieve this
with the following code.

Dim ds As localhost.MyDataSet
Dim s As New localhost.Service1
ds = s.GetMyDataSet()

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
moondaddy
Guest
Posts: n/a
 
      17th Apr 2004
It doenst compile for me.

wsMain is the web reference in the winforms project
dsUser is the typed dataset in both the client app and in the server
webservice

Dim dataService As wsMain.wsMain = GetWebServiceReference(username,
password)

Dim ds As dsUser
ds = dataService.Authenticate()
I get a squigly undeer "dataService.Authenticate()"
Here the squibly say:
Value of type 'CharmpixAdmin_01.wsMain.dsUser' cannot be converted to
'CharmpixAdmin_01.dsUser'.

and if I try

Dim ds As dataService.Authenticate()

I also get a squigly undeer "dataService.Authenticate()"
Here the squigly says "Typed 'dataService.Authenticate' is not defined."






--
(E-Mail Removed)
"Kevin Yu [MSFT]" <v-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi moondaddy,
>
> First of all, I would like to confirm my understanding of your issue. From
> your description, I understand that you need to cast an untyped DataSet
> returned from web service to a typed one. If there is any

misunderstanding,
> please feel free to let me know.
>
> We cannot cast an untyped DataSet to a typed one directly. However, as far
> as I know, we can return a typed DataSet from a web method. If you are
> referencing a web service in your project, the proxy will create the
> definition of the typed DataSet automatically for you. So you can create
> strong typed DataSet object directly from the client machine.
>
> If you are returning a typed DataSet named MyDataSet, you can achieve this
> with the following code.
>
> Dim ds As localhost.MyDataSet
> Dim s As New localhost.Service1
> ds = s.GetMyDataSet()
>
> HTH. If anything is unclear, please feel free to reply to the post.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>



 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      20th Apr 2004
Hi moondaddy,

This doesn't complie because "Dim ds As dsUser" is incorrect. Because
dsUser refers to the typed DataSet on the client side. Although dsUser and
wsMain.dsUser may have the same name and maybe same schema, the compiler
regards them as different objects, and they cannot be casted between each
other. So please try to use the following instead.

Dim ds As wsMain.dsUser

I assume that the dsUser is also defined in the web serivce, so that VS.NET
IDE will create the same class in proxy.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert a untyped DataSet object to an strongly typed DataS =?Utf-8?B?R2VyZGE=?= Microsoft ADO .NET 4 9th Sep 2005 08:44 AM
convert untyped datatable/dataset into strongly typed Somebody_Out_There Microsoft ADO .NET 2 15th May 2004 12:12 AM
convert untyped datatable/dataset into strongly typed Somebody_Out_There Microsoft C# .NET 1 14th May 2004 09:40 PM
Convert a class(strongly typed dataset) into an interface Jeff Microsoft C# .NET 7 3rd Dec 2003 01:55 PM
Cast weakly typed DataSet to a strongly typed dataset??? Microsoft Dot NET 0 18th Sep 2003 10:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:13 AM.