As an exercise, I've been trying to build the database application described in the first chapter of an earlier edition (the 2nd) of Head First C#. (Chapter 1 on O'Reilly website).
I've had to make some modifications because said book is rather ancient, but now it works. It has a SQL Server (LocalDB
) database, ContactDB.mdf
, containing only one table, People
.
The only thing is, every time I run the exe for the first time (after starting up Windows), I get a SqlException
mentioning a time-out. The message is in Dutch, and I would put the English equivalent of it here if I could find it. But despite the same error number, the messages I encounter on the web are different. The message I get refers to a handshake (again, sorry for the language):
System.Data.SqlClient.SqlException (0x80131904): Connection timeout exceeded. The timeout period has elapsed when attempting to use the pre-login handshake confirmation. A possible cause is that the pre-login handshake failed or the server was unable to respond in time. The time spent trying to connect to this server was - [Pre-Login]-initialization=16271; handshake=0;
System.ComponentModel.Win32Exception (0x80004005): Request timed out
If I close the application and start it a second time, I don't get the error.
Doing some research, I find that possible causes for a time-out can be a query that takes a long time (my People
table contains 6 rows) or a firewall issue. Can it be a firewall problem if the application always runs fine the second and subsequent times?
Or should I set a different time-out value?
Any thoughts would be much appreciated.