Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

unable to connect to SQL server from visual studio

$
0
0

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.




Viewing all articles
Browse latest Browse all 8428

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>