SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
Patrick Hill-489170
Patrick Hill-489170
Grasshopper
Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)

Group: General Forum Members
Points: 23 Visits: 29
Sean Lange (1/17/2013)
Patrick Hill-489170 (1/17/2013)
Sean Lange (1/16/2013)
Patrick Hill-489170 (1/16/2013)
I know this is an old thread but figured I would post here instead of creating a new one. I too am having this issue. The odd thing is I get the error when I try to connect to the SQL Server using .NET code( VB.NET or C#). However, I tried using VB6 and it connects to the DB just fine and pulls the data(using the EXACT same connection string).

Remote connections is enabled, TCP/IP and naming pipes are enabled, I added both the TCP port 1433 and UDP port 1434 enabled in windows firewall and remote connections is enabled, I'm able to ping the IP of the server as well. I just find it really really odd that I can connect via a VB6 app but not a .NET app. Does anyone have any other ideas what I can try?



Using the EXACT same string in VB6 and .NET is probably the issue. It is very likely you don't want the same string because it is likely you are not making the same type of connection. Check out http://www.connectionstrings.com/


I checked connectionstrings.com this is the connection string I'm using:

Server=Servername\InstanceName;Database=FireSaftey_Test;User Id=fs_admin;
Password=****;


So you said you can't connect. What is the actual message?



"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)"

I can connect with VB 6, I can connect when I open up management studio and connect to the server. I can even create a .udl file and connect that way. I just can't get it to connect using .net

VB 6 code that connects:

cn.Provider = "sqloledb"
provStr = "Server=SSQLDBAT014001\RLSOLUTIONS;Database=FireSafety_Test;User Id=fs_admin;Password=******"
cn.Open provStr




VB.Net Code that gives me that error:

Imports System.Data.SqlClient

Public Class Form1

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

Dim cn As New SqlConnection
cn.ConnectionString = "Server=SSQLDBAT014001\RLSOLUTIONS;Database=FireSafety_Test;User Id=fs_admin;Password=******"
cn.Open()


sivarao.n
sivarao.n
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 2
Hi All,

We are also getting same error message in production server intermittently.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="en-US">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)</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException i:nil="true"/><Message>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)</Message><StackTrace> at TPUSA.PWASolution.PSIExtension.ExceptionHandlingWCF.LogEvent(String errorMsg, String eventTrace, String eventType, DateTime Logdate)
at TPUSA.PWASolution.PSIExtension.ProjectTaskData.GetAllTasksData()
at SyncInvokeGetAllTasksData(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><Type>System.Data.SqlClient.SqlException</Type></ExceptionDetail></detail></s:Fault></s:Body></s:Envelope>


Please help me to reslove this error.
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25797 Visits: 17509
sivarao.n (8/5/2014)
Hi All,

We are also getting same error message in production server intermittently.

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="en-US">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)</faultstring><detail><ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><HelpLink i:nil="true"/><InnerException i:nil="true"/><Message>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)</Message><StackTrace> at TPUSA.PWASolution.PSIExtension.ExceptionHandlingWCF.LogEvent(String errorMsg, String eventTrace, String eventType, DateTime Logdate)
at TPUSA.PWASolution.PSIExtension.ProjectTaskData.GetAllTasksData()
at SyncInvokeGetAllTasksData(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><Type>System.Data.SqlClient.SqlException</Type></ExceptionDetail></detail></s:Fault></s:Body></s:Envelope>


Please help me to reslove this error.


Intermittent suggests a network issue. Maybe the server goes offline or you have some other kind of network issues. If the same code connects sometimes but not others that is almost always the case.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
adam.klimczyk
adam.klimczyk
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 15
Having the same problems as described above. I have already:
Enabled TCP/IP
Added Exception to the Firewall / disabled Firewall to see if it helps
Checked if the server is up and running - it is.
See below screenshots:




It's my first time with SQL - just following the book and I'm stuck on one of the first pages (600 more to go!)
jiteshhirani1411
jiteshhirani1411
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 21
Your connection String should be Like
"Data Source=ServerName\ServerInstance;Initial Catalog=DatabaseName;user id=userID; password=password;"
Shafat Husain
Shafat Husain
SSC Veteran
SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)

Group: General Forum Members
Points: 234 Visits: 186
Hi,

Check SQL Server Browser service. Is it ON?

Regards,
Shafat Husain
:-)
And Your Lord Never Forgets...!! (64:19 -- Quran)
adam.klimczyk
adam.klimczyk
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 15
Hi,
Thank you both for the help. I've managed to solve it myself.
Simple thing - the server name I should be connecting to is ".\SQLEXPRESS", not "."...
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search