5

I'm confused in those two terms I want to know what is the difference between the timeout inside the connection string and the timeout inside the IIS configuration

data source=xxxx;Initial Catalog=Test;User=yy;Password=yyyy;Timeout=10

enter image description here

Sora
  • 2,465
  • 18
  • 73
  • 146

2 Answers2

3

DB connection timeout is very diffrent from IIS time out

DB connection timeout is about establis the connection to DB, from MSDN SqlConnection.ConnectionTimeout

Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.

From MSDN about Connection Timeout

Connection timeouts help reduce the amount of memory resources that are consumed by idle connections. Time-out settings also allow you to specify how long server resources are allocated to specific tasks or clients.

Mzf
  • 5,210
  • 2
  • 24
  • 37
  • if i reduced the Connection time out to 10 sec for example what kind of error or problems may accrue ? – Sora Jun 05 '13 at 09:08
  • reduce it in DB or IIS ? if DB than if your DB will not response quickly then you will get an error. If IIS then is connection will be idle for the connection timeout period the resources will be free – Mzf Jun 05 '13 at 09:11
  • I meant in IIS not in DB and is there an example where can i throw that error and see how it work ? in my scenario i have a page where i can upload a huge excel file notice huge mean it contains more than 15 000 row and sometime in the upload process it throws that kind of error so we r confused if we should maximize the timeout in connection string or the IIS timeout – Sora Jun 05 '13 at 09:20
  • 1
    Increase the DB timeout - since the IIS connection is not Idle. But, are you trying to save all rows at once? – Mzf Jun 05 '13 at 09:23
  • we had that other problem that we read the excel file and convert it to a DataTable than we use a Stored Procedure to insert those row in the DB but it's too slow i can't change the Stored Procedure code so do u have a best solution for that ? – Sora Jun 05 '13 at 09:26
  • You can use bulk insert - did you try it ? or insert 1000 rows at a time. Need to understand more in order to give better option. if you insert large amount of data , you can lock the table and cause other user query to fail. – Mzf Jun 05 '13 at 09:30
  • i can't change the stored procedure content so i can't use bulk insert but i read about SQLBulkCopy class but it turned out i can't use it with stored Procedure .. one more question can i set the IIS connection time out just for one page not for the whole website ? – Sora Jun 05 '13 at 09:35
  • if the SP take long time try to split the rows. not a master at IIS configuration , maybe this can help http://stackoverflow.com/questions/6379259/how-to-set-different-timeouts-for-different-urls-in-asp-net – Mzf Jun 05 '13 at 09:38
2

The timeout in the database connection string is the amount of time ADO.NET should spend trying to connect to a database server before deciding it is unavailable (which is unrelated to the command timeout, note). Connect in a database connection string is a synonym for Connect Timeout.

The timeout in IIS is how long it should spend trying to process a request before deciding that it has failed.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • so if for example i am uploading a large file to the server and that file took more time than the IIS connection time out would it give me an error ? – Sora Jun 05 '13 at 09:10