Greetings expert programmers,

May i ask for a help on how to solve this error?

" A network-related or instance specific error occured while
establisihing 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 don't know if this problem is in mssql or in vb. sorry if i post this in the wrong category.

Thank you in advance.

Recommended Answers

All 4 Replies

Plz post your code so we can help you.


Ok, this is my connection string:

            Dim buildConString As New StringBuilder
            buildConString.Append("data source=JAKE-PC\SQLEXPRESS")
            buildConString.Append("; Initial Catalog=Ticketing")
            MsgBox("Successful Connection")
            _connectionString = buildConString.ToString()
            _prmList = New List(Of SqlParameter)

        Catch notConnect As Exception
        End Try

This is my stored procedure code:

Public Function GetDataFromStoredProcedure(ByVal spName As String) As DataTable
        Dim ds As New SqlDataAdapter
        Dim dt As New DataTable
        Dim cmd As New SqlCommand
        Dim con As New SqlConnection(_connectionString)

            _success = True
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = spName
            cmd.Connection = con
            If _prmList.Count > 0 Then
                For Each prm As SqlParameter In _prmList
            End If
            ds.SelectCommand = cmd

        Catch ex As Exception
            _success = False
            _message = ex.Message
            ds = Nothing
            con = Nothing
            cmd = Nothing
        End Try

        Return dt
    End Function

And this is the code where i fetch the stored values in dbo.Movies:

Dim dbCon As New DbConnection
        With dbCon
            'DataGridView1.DataSource = table
        End With

Guys need help please :(

Do you remember the connection string I gave you in your previous post "Need Help"?
Try using that one instead.

If I recall correctly, the constant DATA_SOURCE already contains "data source=JAKE-PC\SQLEXPRESS", so what you have done in your StingBuilder is declare the data source twice.
It's redundant, and causes errors.

And, the format of your connection string is targeted towards MSSQL 2005/2008.
Try using "Integrated Security=SSPI" instead of "trusted_connection=yes;".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.