[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

Re: How do I return recordset via webservice?

Tom Vande Stouwe MCSD.net

7/18/2003 6:20:00 PM

1st Forget Record set, think Dataset:

In your service.asmx: (Assuming SQL imports, otherwise use ODBC imports)

<WebMethod()> _
Public Function MyFirstService(Optional Parameters) as dataset
dim oConn as new SQLConnection("Connection String")
dim oSQLCmd as string = "Select..."
dim oCoAd as new SQLDataAdapter(oSQLCmd.oConn)
dim dsHoldingSet as new dataset
oCoAd.fill(dsHoldingSet,"Name for set")
return dsHoldingSet
end Function

This will pull a SQL set that is the result of the "Select..." (or could be
a SP) and the results are contained in he dataset. If multiple tables were
returned, then they will be all in the single set that is returned to the
caller as a dataset.

Let me know if you need more help
==========================================
=Tom Vande Stouwe MCSD.net, MCAD.net, MCP
=45Wallstreet.com (www.45wallstreet.com)
=(803)-345-5001
==========================================
=If you are not making any mistakes
..=..you are not trying hard enough.
==========================================
"Wil Jensen" <wjensen@sigins.com> wrote in message
news:%23qYWc39SDHA.940@TK2MSFTNGP11.phx.gbl...
> Still kinda new at this sorry for the newb level questions.
>
> I'm writing an app where I basically want to pass queries to a webservice
> and have the web service return recordsets to the client (in essence the
web
> server will be the middleman between the remote app and the DB). I'm
> assuming the recordsets would be good in text form as XML, but I'm open to
> whatever is best. It's not critical/confidential data so I'm not really
> worried about encrypting it going across the web.
>
> So in the web service I've got everything set to where I can have a
> DataReader for the recordset, but I don't know how to return that back
> through the web service. Here's the method which I need help with, the
> question marks <??> point out my most confused points.
>
> '============================================
>
> <WebMethod()> Public Function getRemoteRS(ByVal strSQL As String) As
> <??>
> Dim objRS As New SqlDataReader
>
> objRS = getRS(strSQL)
> <
> ??
> >
> getRemoteRS = <??>
> End Function
>
>
> Private Shared Function getConn(ByVal strConn As String) As
> SqlConnection
> Return New SqlConnection(strConn)
> End Function
>
>
>
> Private Shared Function getSQLCmd(ByVal strSQL As String, _
> ByVal
> objDBConn As SqlConnection) As SqlCommand
> Dim objCmd As New SqlCommand(strSQL, objDBConn)
> objCmd.CommandType = CommandType.Text
> Return objCmd
> End Function
>
>
>
> Private Shared Function getRS(ByVal strSQL As String, _
> ByVal strConn As
String)
> As SqlDataReader
> Dim strConn As String = "connection string here"
> Dim objConn As SqlConnection = getConn(strConn)
> Dim objCmd As SqlCommand = getSQLCmd(strSQL, objConn)
>
> objConn.Open()
> Return objCmd.ExecuteReader()
> End Function
>
>
>
>