Hi,
I'm creating a webservice to expose, now I've done the code, the thing is I have a function which calculates how many times my web service has been accessed and I need to combine it with a function which displays a table from a SQL Server, here's the code as my explanation is a bit confusing!
<code>
<%@ WebService language="VB" class="Sales" %>
Imports System
Imports System.Web.Services
Imports System.Xml.Serialization
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web
Imports System.Configuration
<WebService(Description:= _
"My Web Service ", _
Namespace:= _
" _
)> _
Public Class Sales
Inherits WebService
<WebMethod(Description:= _
"Display DataGrid")> _
Public Function DisplayData() As DataSet
Dim dst As New DataSet
Dim dad as sqlDataAdapter
Dim conn as sqlConnection
'provide connection string to connection object
conn=new sqlConnection("My Server details")
'sql select instruction to data adapter
dad=new sqlDataAdapter("select * from mytable",conn)
'use dataadapter to fill dataset
dad.fill(dst,"mytable")
'return dataset
Return dst
End Function
<WebMethod(Description := "Number of times this service has been accessed.")> _
Public Function Counter() As Integer
' If the XML Web service method hasn't been accessed, initialize
' it to 1.
If Application("appMyServiceUsage") Is Nothing Then
Application("appMyServiceUsage") = 1
Else
' Increment the usage count.
Application("appMyServiceUsage") = _
CInt(Application("appMyServiceUsage")) + 1
End If
Return CInt(Application("appMyServiceUsage"))
End Function
End Class
</code>
So I want to combine the Counter Function with the DisplayData Function so the result will be a dataset and a integer both being returned from the same function?
Thanks in Advance
Rich
I'm creating a webservice to expose, now I've done the code, the thing is I have a function which calculates how many times my web service has been accessed and I need to combine it with a function which displays a table from a SQL Server, here's the code as my explanation is a bit confusing!
<code>
<%@ WebService language="VB" class="Sales" %>
Imports System
Imports System.Web.Services
Imports System.Xml.Serialization
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web
Imports System.Configuration
<WebService(Description:= _
"My Web Service ", _
Namespace:= _
" _
)> _
Public Class Sales
Inherits WebService
<WebMethod(Description:= _
"Display DataGrid")> _
Public Function DisplayData() As DataSet
Dim dst As New DataSet
Dim dad as sqlDataAdapter
Dim conn as sqlConnection
'provide connection string to connection object
conn=new sqlConnection("My Server details")
'sql select instruction to data adapter
dad=new sqlDataAdapter("select * from mytable",conn)
'use dataadapter to fill dataset
dad.fill(dst,"mytable")
'return dataset
Return dst
End Function
<WebMethod(Description := "Number of times this service has been accessed.")> _
Public Function Counter() As Integer
' If the XML Web service method hasn't been accessed, initialize
' it to 1.
If Application("appMyServiceUsage") Is Nothing Then
Application("appMyServiceUsage") = 1
Else
' Increment the usage count.
Application("appMyServiceUsage") = _
CInt(Application("appMyServiceUsage")) + 1
End If
Return CInt(Application("appMyServiceUsage"))
End Function
End Class
</code>
So I want to combine the Counter Function with the DisplayData Function so the result will be a dataset and a integer both being returned from the same function?
Thanks in Advance
Rich