Note that there are some explanatory texts on larger screens.

plurals
  1. POPerformance tips/hints for .NET webservice providing info from sql server
    primarykey
    data
    text
    <p>I have a rather simple web-service which exposes data from sql server. It will be used to synchronize data between 2 different databases (SQL Server and Lotus Notes). We're in the stage of testing the web-service and poll it with 20 req./min., the first 2 minutes it goes OK, but after the second, we're getting an exception, obviously the connection (to the database) can't be opened(timeout).</p> <p>Do you have any tips/recommendations on what to do or where to look at? The web-service has been programmed using C#/.NET, the connection to the db is opened during construction of (web-service) object and closed when the object is disposed. </p> <p>I've considered using global.asax to "share" the connection but after some googling I found out most people find that a bad idea and I'm looking for a different solution.</p> <p>ps. the service is pooled in a synchronous way, no 2 requests exist at the same time</p> <p>-edit- (after first 2 anwsers about pooling) This is current code:</p> <pre><code>public class DataService : System.Web.Services.WebService { private SqlConnection conn = new SqlConnection("Data Source=ip;database=database;uid=user;pwd=secret;"); public DataService () { try { conn.Open(); } catch (Exception dbconn) { throw new SoapException("Couldn't open connection to database:" + dbconn.Message + " More info at: " + dbconn.HelpLink, errorCode); } //Uncomment the following line if using designed components //InitializeComponent(); } ~DataService() { conn.Close(); } [WebMethod(Description="Gets all Person changes(from last week)")] public Person[] GetPerson() { Person[] Personen = null; SqlCommand sqlcmd = conn.CreateCommand(); sqlcmd.CommandText = "SELECT * FROM Person"; SqlDataReader Rows = sqlcmd.ExecuteReader(); while (Rows.Read()) { //doSomething } Rows.Close(); return Personen; } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload