Tuesday, June 28, 2016

SQL Server Doesnot exists or Access Denied (SOLVED)

During recent database migration from SQL Server 2005 to SQL Server 2012, we faced a issue where while trying to connect to SQL Server 2012 database from Visual studio was resulting in an error "SQL Server does not exist or acess denied".
After breaking head for some time i could figure out the problem. The problem was related to the attributes used in the connection string. The connection string with old attributes or format was not able to connect to SQL Server 2012 database.
Lets look at the old connection string attributed and new connection string attributes.

The connection string which worked from Visual Studio to SQL Server 2005:

<add key="connection" value="server= VAIO;User ID= test_user;Password=#######;database=master;connection reset=false;" />

"SQL Server does not exist or acess denied" error was thrown when the connection string with same attributes was used to connect to SQL Server 2012 server.

Correction required in Connection string attributes is as follows:
<add key="connection" value="Data Source=VAIO;Initial Catalog=master;Persist Security Info=True;User ID=test_user;Password=#######"/>

The following attribute changes can be noticed:

Old Attribute New Attribute
server Data Source
database Initial Catalog
connection reset Persist Security Info

Hope this helps.