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.

Plz post your code so we can help you.

Sorry.

Ok, this is my connection string:

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

        Catch notConnect As Exception
            MsgBox(notConnect.Message)
        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)

        Try
            _success = True
            con.Open()
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = spName
            cmd.Connection = con
            If _prmList.Count > 0 Then
                For Each prm As SqlParameter In _prmList
                    cmd.Parameters.Add(prm)
                Next
            End If
            ds.SelectCommand = cmd
            ds.Fill(dt)

        Catch ex As Exception
            _success = False
            _message = ex.Message
            MsgBox(ex.Message)
        Finally
            con.Dispose()
            cmd.Dispose()
            ds.Dispose()
            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
            .GetDataFromStoredProcedure("[dbo].[usp_getMovies]")
            '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, networking, learning, and sharing knowledge.