February 10, 2011 at 7:01 am
Hi,
We have a software, design in vb.net, that automatically load in the startup of Windows. First thing, this program try to connect to a local SQL Server 2008 Express database. What I don't understand is the fact that, as long as the computer is not connected to the network, the program can't connect to the local instance of SQL. As soon as the network is available, the connection succeed. In our case, it can take up to 25 seconds between the reboot and the network connection. During this time, it's impossible to connect to the SQL Server.
Error message given is the following:
System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
connection string uses SQL Server security and server would be "server/instance" format.
thanks for your time and help
February 10, 2011 at 8:12 am
that seems perfectly normal to me. Your application needs to smart enough to handle the fact that SQL server may not be available for any number of reasons, but most commonly after a reboot and until the service has started.
The probability of survival is inversely proportional to the angle of arrival.
February 10, 2011 at 8:54 am
thanks for the reply. We had modified the program to loop and wait for the network to be available before connecting to SQL. But I don't understand the relation between the network and the connection to a local instance of SQL. We checked and the SQL service is running when we try to connect immediatly after a reboot. So, why does the network has to be available??! I don't get it.
February 10, 2011 at 9:06 am
You can specify the protocol in your connection string - for a local instance you can use shared memory instead of TCP/IP (in fact That is recommended for local instances). Otherwise you will need to wait until the system TCP stack is initialized and SQL Server creates the endpoint, although that should not take very long after the OS is initialized.
Your app should expect to possibly wait for some period of time before the SQL instance is available whether it is a local instance or not. The reasons are varied but your software should wait and retry the connection attempt. After X amount of time being unable to connect you want to report an error/alert or take alternate action (perhaps connect to a standby server, etc.)
The probability of survival is inversely proportional to the angle of arrival.
February 10, 2011 at 9:19 am
I will go look at how to connect to SQL from shared memory then.
thanks for the reply!
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy