[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Asier

6/5/2004 3:14:00 PM

Hello,

I've a webService thar read from my database and let results in a
SqlDataReader. I want to return this datreader to my ASP.NET page but it
fail.
This is my code:
***************************

Dim cnConexion As New SqlConnection("..................")

<WebMethod()> Public Function fLeerTodasCIAs() As SqlDataReader

Dim drCIAS As SqlDataReader

Dim cmd As New SqlCommand("spCIASLeerTodas", cnConexion)

cmd.CommandType = CommandType.StoredProcedure

cnConexion.Open()

drCIAS = cmd.ExecuteReader(CommandBehavior.CloseConnection)

drCIAS.Close()

End Function

**************************

What is the problem?? thanks

Asier


1 Answer

Sami Vaaraniemi

6/6/2004 12:01:00 PM

0


"Asier" <asieraies@euskalnet.net> wrote in message
news:u2tBb8vSEHA.3332@tk2msftngp13.phx.gbl...
> Hello,
>
> I've a webService thar read from my database and let results in a
> SqlDataReader. I want to return this datreader to my ASP.NET page but it
> fail.
> This is my code:
> ***************************
>
> Dim cnConexion As New SqlConnection("..................")
>
> <WebMethod()> Public Function fLeerTodasCIAs() As SqlDataReader
>
> Dim drCIAS As SqlDataReader
>
> Dim cmd As New SqlCommand("spCIASLeerTodas", cnConexion)
>
> cmd.CommandType = CommandType.StoredProcedure
>
> cnConexion.Open()
>
> drCIAS = cmd.ExecuteReader(CommandBehavior.CloseConnection)
>
> drCIAS.Close()
>
> End Function
>
> **************************
>
> What is the problem?? thanks

You cannot return an SqlDataReader from a Web service as an SqlDataReader is
not serializable over SOAP. Instead, return a DataSet or an array of custom
objects. For an example on how to return a DataSet, see:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconconsumingdatasetfromwebs...

Regards,
Sami