Greetings expert programmers,

Can someone guide me on how i will connect my vb.net 2008 to ms sql 2008 r2?

I already installed mssql 2008 r2, and when i try to add the connection it says i need to call the administator something like that even though i checked all the permission.

Is there another way on how to connect to mssql? if yes, please guide me.

Thank you in advance.

how are you trying to connect.

ok i already have the code for connecting vb to mssql but i'm having error on it.

The error says:

" network-related or instance-specific error occurred while establishing a connection to sql server. The server was not found or was not accessible. very 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."

That's the error i get from the connection.

could you please post us your connectionstring?

Here's the code

Dim buildConString As New StringBuilder
        buildConString.Append("data source=JAKE-PC\SQLEXPRESS")
        buildConString.Append(DATA_SOURCE)
        buildConString.Append("; database=Ticketing")
        buildConString.Append(DB_NAME)
        'buildConString.Append("; user id=")
        'buildConString.Append(DB_USER)
        'buildConString.Append("; password=")
        'buildConString.Append(USER_PWD)
        buildConString.Append(";trusted_connection=yes;")

        _connectionString = buildConString.ToString()
        _prmList = New List(Of SqlParameter)
        _prmList.Clear()
Public Sub ExecuteStoredProcedureWithReturnValue(ByVal spName As String)
        Dim cmd As New SqlCommand
        Dim con As New SqlConnection(_connectionString)
        Dim result As Short = 0
        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

            result = CType(cmd.ExecuteScalar, Short)
            If result = 1 Then
                _success = True
                MsgBox("Successful connection")
            End If
        Catch ex As Exception
            _success = False
            _message = ex.Message
            MsgBox(ex.Message)
        Finally

            con = Nothing
            cmd = Nothing
        End Try

    End Sub
Dim dbHelper As New DbConnection
        With dbHelper
            .ExecuteStoredProcedureWithReturnValue("data source=JAKE-PC\SQLEXPRESS; database=Ticketing; trusted_connection=yes;")
        End With

I'm starting to see a pattern here.
Try this connection string, without using a StringBuilder.

_connectionString = "Data Source=JAKE-PC\SQLEXPRESS; Inital Catalog=Ticketing; Integrated Security=SSPI"

And the connection string cannot be passed as the name of a Stored Procedure.
It has to be the name of an existing Stored Procedure in the database server.

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.