Cannot Connect to SQL Server from Another Computer - c#

I have been going at this for hours, but have had no success with the current posts out there.
Tried methods:
Enabling TCP
Allowing Remote Connections for the database
Adding new inbound and outbound rules
All these things still do not let me login from my other computer. When I connect on my main computer, everything is instant, but when I tried on my secondary one, it takes a long time before giving me the error:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326)
Is there anyway of fixing this? I don't think watching more Youtube tutorials will help.

Related

Intermittant SQL Server connection Issues

I maintain a system of automated data processing machines which run processes written in C# that are controlled by an SQl Server 2014 Enterprise Edition Database. Several times a day all of the processes on one machine will start receiving the following error:
An error has occurred. Details of the exception: 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) Unable to connect to SQL Server database.
All processes on the machine will experienc the same error when attempting to contact the database. After 10 or 15 minutes the machine will be able to connect again. While this is happening other machines on the same network will be able to connect no problem. We have checked the database - SQL Server is running - it is not blocked it is accepting connection, the instance name is correct. This is an intermittant problem that does not affect all machines connecting to the database but when it affects one - all processes experience the error. I have searched on this message and all the answers I have found are for constant failures - not intermittant like I am experiencing.
UPDATE
Found this on another question - Am testing now looks good:
The problem was that SQL was configured to allow both TCP and Named Pipes. Sometimes it would try and connect with the latter which doesn't use the standard SQL port. The solution was to prefix the data source/server in the connection string with Data Source=tcp:xxx.xxx.xx.xxx to always ensure it connects via TCP
The problem was that SQL was configured to allow both TCP and Named Pipes. Sometimes it would try and connect with the latter which doesn't use the standard SQL port. The solution was to prefix the data source/server in the connection string with Data Source=tcp:xxx.xxx.xx.xxx to always ensure it connects via TCP

Occasional Exceptions: "A network-related or instance-specific error occurred while establishing a connection to SQL Server"

Occasionally our web application throws:
System.Data.SqlClient.SqlException (0x80131904): 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) ---> System.ComponentModel.Win32Exception (0x80004005): The network path was not found
Now I have Googled maybe all kinds of variations regarding this error but all seem to point to the fact that the destination SQL server is either down or doesn't accept remote connections or something wrong with the connection string.
But my scenario is different, I can definitely reach the SQL Server (separate machine, same LAN) and this application runs normally most of the time, but in certain instances it starts to generate these errors. Then, apparently, they stop on their own then randomly they start again. Other applications on the same server to the same SQL Server (though different databases) throw these errors as well during the same period.
I have left a continuous ping between the two servers and I can confirm that during this period both servers have IP connectivity between them.
What could be the cause of this problem? What can I check next?
Did you make sure that TCP/IP is enabled under Sql Server Configuration management->SQL Server network config->protocols ?

Windows service network error

I have made a windows service and through that service I am doing operations on the database. The machine that I have installed the service is in India and the server is in Singapore. When this service runs I get an error such as
" 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: TCP
Provider, error: 0 - No connection could be made because the target
machine actively refused it.) "
I have a connection string such as
return "server=122.0.122.222,5222;database=ABCD;user id=abc101;password=xyz";
this is in a function that is returning a string. I am catching this string in another string and passing it to the connection object.M I doing anything wrong here.?
But I have tested this service at my house. It works just fine. But when deployed at clients end I get the above error. Any idea why this mite be happening.? Is it related to internet connection but the internet connection is fine. DO I have to give some permissions from my service to make a connection or the IT team of the client should have to give some permissions at their end.?
Please help.
Thanks In advance

provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

i am developing a web application in visual studio 2012. and i have added a database file named as Database1.mdf into App_Data folder and i have given following connection string
Data Source=(LocalDB)\v11.0;AttachDbFilename="E:\asp.net mvc\storage\storage\App_Data\Database1.mdf";Integrated Security=True
after that i have written the code for inserting the data but at that i am getting the error like
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: Named
Pipes Provider, error: 40 - Could not open a connection to SQL Server)
is there any mistake in the connection string?
Please help me in htis
Usually, for me, this indicates that SQL Server hasn't been configured correctly to receive remote calls. There are three things to check.
Your server instance is named correctly and you have permissions to it
That you are configured to receive remote connections
That SQL server is open on the the protocols you want to use
To check the second one, open up SQL Management Studio and select Properties on the server. Then check under "Connections" that "Remote Server Connections" is enabled.
To check the third, open up SQL Server Configuration Manager and make sure that "Client Protocols" TCP/IP is enabled as well as Named Pipes (depending on your network setup).
Your connection string should be written like this:
connectionString="DataSource=.\SQLEXPRESS; InitialCatalog=Database; AttachDBFilename=|DataDirectory|\Database.mdf; Integrated Security=SSPI;"

error in connect to sqlserver in windows and sql authentication mode

i have a snippet that it work properly when i use windowsmode with follow connection string
data source=.;database=xDB;integrated security=true;
but i have to change it for sql and windows mode i changeit to
Data Source=.;Initial Catalog=xDB;User Id=krs;Password=12345;
but follow error occur
Login failed for user 'krs'. The user is not associated with a trusted SQL Server connection.
and when change dot(.) to(local) another error occur
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
plz help me im beginer n confused.thank
You have to enable the Named Pipe & TCP/IP in SQL Server configuration. Go through following link to enable that
http://www.triostechs.com/Microsoft-SQL-Server-2008/Microsoft-SQL-Server-2008-Enable-TCP/IP-or-Named-Pipes.html
Also Make sure, only one instance of the SQL Server running. If it is more than one, just verify which one you are connecting to.

Categories

Resources