我们在ASP.NET 2.0 Web服务(VB)中创建了WebMethod
,可以非常频繁地在整个应用程序中访问它。 WebMethod
将查询作为参数获取并返回DataSet
。当用户数为1或2时,它可以正常工作。如果~30个用户同时使用系统, WebMethod
会返回不同查询的DataSet
。我们已经尝试了synclock
(C#中的lock
)选项,但它不起作用。
Public Function ExecuteQry(ByVal StrText As String) As DataSet
Dim AdoDs As New DataSet()
Dim SqlDp As New SqlDataAdapter
Dim SqlCmd As New SqlCommand
Dim SqlParam As New SqlParameter
Try
SyncLock AdoDs
MakeConnect()
With SqlCmd
.Connection = SqlCon
.CommandText = "rExecuteQry"
.CommandType = CommandType.StoredProcedure
End With
SqlParam = SqlCmd.Parameters.AddWithValue("@strText", Trim(StrText))
SqlDp.SelectCommand = SqlCmd
SqlDp.Fill(AdoDs)
DisposeConnect()
Return AdoDs
End SyncLock
Catch ex As SqlException
DisposeConnect()
Debug.Write(ex.Message)
Finally
SqlCmd = Nothing
SqlParam = Nothing
End Try
End Function
以下是存储过程:
ALTER PROCEDURE [dbo].[rExecuteQry]
@strText Varchar (max)
as
Exec( @StrText)