Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Connection Error

Connection Error

Scheduled Pinned Locked Moved Visual Basic
databasecsharpsql-servervisual-studiosysadmin
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    reykentj
    wrote on last edited by
    #1

    Environment: Op Sys 2003 server; Sql Server 2005 with update; Visual Studio; Multiple VB functions and subroutines as stored procedures.This subroutine needs to use a connection string to enable MARS. It does not have the SQL Attributes. They seem to prohibit byref class instantiations being returned. Dim connectionString As String = _ "server=(local);" & _ "Trusted_Connection=yes;" & _ "database=Frontier_equipment;" & _ "MultipleActiveResultSets=true;" RecordTypeConnection = New SqlConnection() RecordTypeConnection.ConnectionString = connectionString RecordTypeConnection.Open() Error Numr 5 Error Desc An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) rkj

    K D 2 Replies Last reply
    0
    • R reykentj

      Environment: Op Sys 2003 server; Sql Server 2005 with update; Visual Studio; Multiple VB functions and subroutines as stored procedures.This subroutine needs to use a connection string to enable MARS. It does not have the SQL Attributes. They seem to prohibit byref class instantiations being returned. Dim connectionString As String = _ "server=(local);" & _ "Trusted_Connection=yes;" & _ "database=Frontier_equipment;" & _ "MultipleActiveResultSets=true;" RecordTypeConnection = New SqlConnection() RecordTypeConnection.ConnectionString = connectionString RecordTypeConnection.Open() Error Numr 5 Error Desc An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) rkj

      K Offline
      K Offline
      kubben
      wrote on last edited by
      #2

      Are you sure your sql server name is correct? Are you sure the sql server allows trusted connection. Can you ping the sql server name from where you are trying to run this app? Is there an instance of a sql server you are trying to connect to? You have to put that into your server name. Sometimes you have to set a port number for sql server instances. Anyway, a few thoughts, I hope that helps. Ben

      R 1 Reply Last reply
      0
      • K kubben

        Are you sure your sql server name is correct? Are you sure the sql server allows trusted connection. Can you ping the sql server name from where you are trying to run this app? Is there an instance of a sql server you are trying to connect to? You have to put that into your server name. Sometimes you have to set a port number for sql server instances. Anyway, a few thoughts, I hope that helps. Ben

        R Offline
        R Offline
        reykentj
        wrote on last edited by
        #3

        I had read that Stored procedures running within the SQL Server could use the local option for server name. Placing the combined servername\sqlservername as the servername worked.!! Thank you.:):) rkj

        1 Reply Last reply
        0
        • R reykentj

          Environment: Op Sys 2003 server; Sql Server 2005 with update; Visual Studio; Multiple VB functions and subroutines as stored procedures.This subroutine needs to use a connection string to enable MARS. It does not have the SQL Attributes. They seem to prohibit byref class instantiations being returned. Dim connectionString As String = _ "server=(local);" & _ "Trusted_Connection=yes;" & _ "database=Frontier_equipment;" & _ "MultipleActiveResultSets=true;" RecordTypeConnection = New SqlConnection() RecordTypeConnection.ConnectionString = connectionString RecordTypeConnection.Open() Error Numr 5 Error Desc An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) rkj

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Along with what kubben said, your connection string says that it expects the database server to be on the same machine as the one where your code is running. I hope this is true, otherwise you'll have to change your connection string. Does your SQL Server instance have Named Pipes enabled?

          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007

          R 1 Reply Last reply
          0
          • D Dave Kreskowiak

            Along with what kubben said, your connection string says that it expects the database server to be on the same machine as the one where your code is running. I hope this is true, otherwise you'll have to change your connection string. Does your SQL Server instance have Named Pipes enabled?

            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            R Offline
            R Offline
            reykentj
            wrote on last edited by
            #5

            The stored procedures are on the same machine as the server. Replacing server(local) with servername\server made the whole thing work.:) rkj

            D 1 Reply Last reply
            0
            • R reykentj

              The stored procedures are on the same machine as the server. Replacing server(local) with servername\server made the whole thing work.:) rkj

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              If it's a stored procedure, you can try "context connection = true" for the connection string to use the connection that the SP is executing under. But, as you can read here[^], this is not always the best idea.

              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              R 1 Reply Last reply
              0
              • D Dave Kreskowiak

                If it's a stored procedure, you can try "context connection = true" for the connection string to use the connection that the SP is executing under. But, as you can read here[^], this is not always the best idea.

                Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                     2006, 2007

                R Offline
                R Offline
                reykentj
                wrote on last edited by
                #7

                I was using that but I needed the MARS capability.:) rkj

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups