Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone

I have an application having a server machine and around 150 clients. server machine is the domain controller as well as sql server.

Two connection strings are used in the application to create connection objects.

For normal quering
(1) Data Source=<servername>;Initial Catalog=<databasename>;User ID=admin;Pooling=True;Min Pool Size=5;Max Pool Size=200

For queries that take large time (only 3 reports are using this connection string)
(2) Data Source=<servername>;Initial Catalog=<databasename>;Integrated Security=False;User ID=admin;Asynchronous Processing=True;MultipleActiveResultSets=True;Connect Timeout=0


Problem:
Some times like once in a month, the application becomes very slow, even showing time-out. The stored procedures execute at normal speed at server machine during this time(all sps). This will solved as soon as the MS SQL Server 2005 is restarted.

This is a sample of code which i generally use to select data...
(soon after adapter.Fill(dt) is executing the application halts, where as the same stored procedure runs with ease.)
C#
public DataTable CollectionByTerminal(DateTime from, DateTime to)
      {
          SqlCommand command = new SqlCommand("sp_name", connection);
          command.CommandType = CommandType.StoredProcedure;
          command.Parameters.AddWithValue("@From", from);
          command.Parameters.AddWithValue("@To", to);

          SqlDataAdapter adapter = new SqlDataAdapter(command);
          DataTable dt = new DataTable();

          try
          {
              adapter.Fill(dt);
              return dt;
          }
          catch (Exception error)
          {
              throw new Exception(error.Message);
          }
          finally
          {
              adapter.Dispose();
              CloseConnection();
          }
      }

Please help me in following areas
Is there any problem by using the same machine for database server as well as domain controller?
Is there any problem with the connection strings?
Is there any problems of using connection pooling, Asynchronous Processing or MultipleActiveResultSets?
Is there any problem in the calling function?

I believe answers to these questions will help me as well as thousands of new programmers

Thank you very much
Anoop
Posted
Updated 20-Sep-11 22:43pm
v3
Comments
Prerak Patel 19-Sep-11 7:44am    
Code block added.
Anoop Ananthan 21-Sep-11 4:39am    
Thank you, Prerakji
Simon_Whale 19-Sep-11 9:18am    
does it error when it hits the adapter.fill? or does it appear to hang? what happens if you let it run?

Have you looked at running SQL server profiler to see what is happening at the same time?
Anoop Ananthan 21-Sep-11 4:47am    
No, no error is generated. Once time-out occurred.
During the execution of adapter.Fill() method, it takes around 10-15 seconds
to complete. During this time i can just run the stored procedure easily (0 second duration)

1 solution

If your sql server gets better after a restart then you have memory limit issues.

Buy more RAM for the server. If you can't then restart the service at midnight every couple of weeks.
 
Share this answer
 
Comments
Anoop Ananthan 19-Sep-11 7:57am    
Thankyou Mehdi for your support,
this once happened with just one client working.
Can that be a memory problem ?
Mehdi Gholam 19-Sep-11 8:02am    
Sounds like it.
Anoop Ananthan 23-Dec-11 1:15am    
Upgraded RAM as per your advice. Now RAM size is 32 GB. We monitored from Sep to Dec 2011, till now no problem has been reported. Thank you.
Mehdi Gholam 23-Dec-11 1:29am    
Good to hear!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900