P
Patriot
I wonder if it is threadsafe to have a Shared Function or Sub like
this:
Public Class Data1
Public Shared Function Query1(Byref sCnxn as String, Byval sSql As
String) As DataTable
Dim oCnxn As New SqlConnection(sCnxn)
Dim oCmd As New SqlCommand(sSql, oCnxn)
Dim oDs As New DataSet
' Mark the Command as a SPROC
oCmd.CommandType = CommandType.Text
oCnxn.Open()
Dim oDa As SqlDataAdapter = New SqlDataAdapter(oCmd)
oDa.Fill(oDs, "result")
oCmd.Dispose()
oCnxn.Close()
Dim dt As DataTable = oDs.Tables("result").Copy
oDs.Clear()
oDs = Nothing
oDa = Nothing
Return dt
End Function
End Class
Will I have any problem with multiple concurrent web requests?
Thanks
this:
Public Class Data1
Public Shared Function Query1(Byref sCnxn as String, Byval sSql As
String) As DataTable
Dim oCnxn As New SqlConnection(sCnxn)
Dim oCmd As New SqlCommand(sSql, oCnxn)
Dim oDs As New DataSet
' Mark the Command as a SPROC
oCmd.CommandType = CommandType.Text
oCnxn.Open()
Dim oDa As SqlDataAdapter = New SqlDataAdapter(oCmd)
oDa.Fill(oDs, "result")
oCmd.Dispose()
oCnxn.Close()
Dim dt As DataTable = oDs.Tables("result").Copy
oDs.Clear()
oDs = Nothing
oDa = Nothing
Return dt
End Function
End Class
Will I have any problem with multiple concurrent web requests?
Thanks