1
votes

I am using following connection string to connect to database on local machine. Problem is that if network goes down then i cannot connect to my database although application is connecting to database on same machine. What am I doing wrong?

add name="MainDb" connectionString="Data Source=MyComputerName,1433;Network Library=DBMSSOCN;Initial catalog=MyLocalDatabase;Integrated Security=False;User=MyUser;Password=MyPassword;"

3
have you tried using loopback ip? (127.0.0.1)Dalen

3 Answers

0
votes

Try to remove Network Library parameter from connection string. This way you are forcing the connection provider to use specific protocol. If you disable networking (TCP), it may be that the provider is not able to connect.

Here's some info about Network Library parameter http://support.microsoft.com/kb/238949

If the Network Library is not provided, application uses protocols in order specified in the SQL Server Configuration Manager, in SQL Native Client 10.0 Configuration, in node Client Protocols. These protocols must be of course enabled on the server side, which in case of the same machine is just located in the SQL Server Network Configuration, in Protocols.

I am using SQL Server 2008 R2, if you are using older, the version of the provider may be different.

Here is a question that looks to be concerned about similar issue:

SQL Server communication protocol issue

Regards

Piotr

2
votes

Use localhost as your computer name. localhost uses a shared memory connection, rather than climbing through the network layer.

Also verify, with sql server configuration manager, that shared memory is enabled.

0
votes

When using DBMSSOCN, try supplying the IP address of the database instance, instead of MyComputerName. As @Dalen suggested, 127.0.0.1

http://www.connectionstrings.com/sql-server

Confirm also what port the instance is running on (usually 1433) and supply that after the IP address:

 Data Source=127.0.0.1,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;