Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2004

Tip: Looking for answers? Try searching our database.

How to pass a typed dataset to a web service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Justin Crossley - 17 Nov 2004 15:52 GMT
I'm having a type mismatch problem when trying to pass a typed dataset to a
web service.

My code is:

CLIENT CODE

I have a dataset schema file called MainData.xsd containing a table called
mytable

'create and fill typed dataset
Dim dsMain As New MainData
Dim con As New SqlConnection("myconnectionstring")
Dim da As New SqlDataAdapter("select * .....", con)
da.Fill(dsMain.mytable)

'pass typed dataset to web service
Dim ws As New localhost.DataTransfer
ws.PassData(dsMain)

WEB SERVICE CODE

The web service also has an identical local file containing the data schema
called MainData.xsd

<WebMethod()> Public function PassData(Value as MainData)
...
End Function

Unfortunately I get an error when I hover over the PassData method that says
'Value of Type MainData cannot be converted to localhost.MainData'.

It is obviously treating the two data types as being different.

If I change the parameter type of the PassData function to type DataSet then
the function can be called OK, but then I lose the type information.

Any ideas anybody?

Thanks

Justin Crossley
Drew Marsh - 17 Nov 2004 16:47 GMT
> I'm having a type mismatch problem when trying to pass a typed dataset
> to a  web service.
[quoted text clipped - 6 lines]
>
> It is obviously treating the two data types as being different.

It's because they are two different data types as far as .NET knows. Even though the MainData you have generated on the client is logically the same because it was generated from the same XSD, it's not the same .NET type. So you have to use the MainData class generated by the web reference.

> If I change the parameter type of the PassData function to type
> DataSet then  the function can be called OK, but then I lose the type
> information.

Yeah, you shouldn't have to go this route though. It's less type specific and what you're doing is a perfectly viable solution. I think you're just getting confused by .NET typing vs. XSD typing.

HTH,
Drew

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.