.net-3.5connection-stringsql-server-expressdatadirectory

Time out exception in 1st run for local DB


My connection string is like the following. It shows 'Timeout Exception' first time I run the application. But, for the subsequent run, it's ok. I think, it might take some time to attach the DB to the SQLExpress Server. Is there anyway to increase Timeout period? Thanks

I am using SQLServer 2005 Express and VS 2008 and .Net 3.5.

<add name="dotnetConnectionString" connectionString="Server=.\SQLExpress;AttachDbFilename=|DataDirectory|dotnet.mdf; Database=dotnet;Trusted_Connection=Yes;" providerName="System.Data.SqlClient"/>  

Solution

  • Use Connection Timeout in your connection string and specify the number of seconds. Try 60 at first.