Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase ««12

A network-related or instance-specific error occurred while establishing a connection to SQL Server Expand / Collapse
Posted Thursday, January 17, 2013 11:33 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 19, 2013 6:45 AM
Points: 7, 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

I checked this is the connection string I'm using:

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

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=******"

Post #1408553
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse