T
Timbo
Hi There,
I have a ASP.NET Web Service that retrieves various data from a SQL 2000
database and returns results to the user. I have written individual
functions for each kind of data set that I'm returning. All was working
fine and now I've scaled it up so that potentially 50 people are making
requests the web service is sometimes hanging. I'm using a hosted server,
so at the moment I'm not sure if its IIS or SQL2000 that is falling over and
re-starting itself.
My main query at the moment is regarding database connections and if I'm
doing it correctly... here is a small example..
<WebMethod(Description:="Updates some data and return a string based on
result.", EnableSession:=True)> _
Public Function SendDate(ByVal Str1 As String, ByVal Str2 As DataSet) As
String
Dim cmd As New SqlCommand
Dim cn As New SqlConnection
cn.ConnectionString = cnStr()
cmd.Connection = cn
..... do some SQL stuff etc...
cn.Close()
cmd.Dispose()
cn.Dispose()
End Function
I have about 20 different functions all doing something different. Is there
an overhead by me declaring the Connection string and Command string
everytime the function is called, could I not just declare them once at the
top of my class? If so would it be thread safe?
Is what I'm doing at the moment opening too many connections to the server
therefore causing it to crash when too many people are making requests?
I hope this makes sense and any advice or best practises would be greatly
received
Thanks.
Tim
I have a ASP.NET Web Service that retrieves various data from a SQL 2000
database and returns results to the user. I have written individual
functions for each kind of data set that I'm returning. All was working
fine and now I've scaled it up so that potentially 50 people are making
requests the web service is sometimes hanging. I'm using a hosted server,
so at the moment I'm not sure if its IIS or SQL2000 that is falling over and
re-starting itself.
My main query at the moment is regarding database connections and if I'm
doing it correctly... here is a small example..
<WebMethod(Description:="Updates some data and return a string based on
result.", EnableSession:=True)> _
Public Function SendDate(ByVal Str1 As String, ByVal Str2 As DataSet) As
String
Dim cmd As New SqlCommand
Dim cn As New SqlConnection
cn.ConnectionString = cnStr()
cmd.Connection = cn
..... do some SQL stuff etc...
cn.Close()
cmd.Dispose()
cn.Dispose()
End Function
I have about 20 different functions all doing something different. Is there
an overhead by me declaring the Connection string and Command string
everytime the function is called, could I not just declare them once at the
top of my class? If so would it be thread safe?
Is what I'm doing at the moment opening too many connections to the server
therefore causing it to crash when too many people are making requests?
I hope this makes sense and any advice or best practises would be greatly
received
Thanks.
Tim