I am having error while connecting to SQL Server:
Details in Stack Trace are:
===================================
Cannot connect to ServerN
When you starting application 'Run as administrator'.This way I avoided this error.
To add on top of @Pranav Singh and @Rahul Tripathi answer. After doing all the mentioned by those 2 users, my .net app still wasnt connecting to the database. My solution was.
Open Sql Server Configuration Manager, go to Network configuration of SQL SERVER, click on protocols, right click on TCP/IP and select enabled. I also right clicked on it opened properties, Ip directions, and scrolled to the bottom (IPAII , and there in TCP Port, I did setup a port (1433 is supposed to be default))
the following points work for me. Try:
I've gotten this error because the user trying to login was lacking permissions.
I don't recommend doing this, but I fixed it by granting the user db_owner
globally. It was a local instance, so not a huge security concern.
For SQL2008,
Restart the server using configuration manager.
Sometimes specifying the database (instead of default) solves this error.