CacheDuration In WebService?

A

Arpan

I successfully created a DLL named "DBServices.dll" using the following
code in a class file:

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Services

Namespace DBServices
Public Class DBServiceSettings : Inherits WebService
Private sqlConn As SqlConnection

<WebMethod()> Public Function QueryDB(ByVal Query As String) As
DataSet
Dim dSet As DataSet
Dim sqlDapter As SqlDataAdapter

sqlConn = New SqlConnection("Data Source=......")
sqlDapter = New SqlDataAdapter(Query, sqlConn)

dSet = New DataSet
sqlDapter.Fill(dSet, "tblName")

Return dSet
End Function
End Class
End Namespace

This is 1-line code in the ASMX page that uses the above DLL to create
a web service:

<%@ WebService Language="VB" Class="DBServices.DBServiceSettings" %>

As such the above ASMX page gets executed perfectly. When the user
comes to the ASMX page, "QueryDB" is rendered as a link clicking which
the next page displays a TextBox to enter a SELECT SQL query. When the
user clicks the "Invoke" Button in the next page, a new browser window
opens up & displays all the records retrieved by the SQL query in XML
format.

Now I did like to cache the web service. Had the code in the class file
existed in the ASMX page, I could have used the CacheDuration property
of the WebMethod attribute but since the class file encapsulates the
logic, I can't use the CacheDuration property in the WebMethod
attribute.

So how do I cache the web service in this case?

Thanks,

Arpan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DB Value in Label 1
Proxy Class Property? 1
Show "No Records Found" Message 1
Default Selected Item in DropDownList 4
Webservice error - please help 2
DataBind 1
DropDownList DataGrid 1
Using WebService In ASPX 2

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top