I am using visual studio ultimate 2013 and SQL server express edition with tools.
I have following connection class to establish connection with SQL server
Imports System.Data
Imports System.Data.SqlClient
Public Class Connect
Public Cnn As New SqlConnection
Public ConnStr As String
Public Sub ConnectDB()
If Cnn.State = ConnectionState.Open Then Cnn.Close()
ConnStr = "Data Source=PRIOSSHRSTH;Initial Catalog=test;Persist Security Info=True;User ID=sa;Password=sa@123"
Cnn.ConnectionString = ConnStr
Cnn.Open()
End Sub
End Class
I get following error on line Cnn.Open()
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)
Remote connection is enabled for SQL server. Both visual basic and SQL server service have been allowed to use all ports in firewall.have also enabled Named pipes and TCP/IP in SQL server 2014 configuration manager. The problem still persists.
So any idea what I can do? Any help would be appreciated.
Thanks.