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. Database & SysAdmin
  3. Database
  4. sql server doesnt allow remote connections![.NET2 sqlserv05exp]

sql server doesnt allow remote connections![.NET2 sqlserv05exp]

Scheduled Pinned Locked Moved Database
sysadmincsharpdatabasesql-serverhelp
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.
  • G Offline
    G Offline
    giddy_guitarist
    wrote on last edited by
    #1

    hi , well thats what JIT says everytime i run an sql server 05 express sample on my pc.Somehow the code that i write for the dbs i've made runs fine. But every sample ive got , including samples from MSDN give me that error. "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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)" Could someone perhaps tell me how to enable remote connections!? I'm quite a newbie with sqlserver. thanks Gideon

    C A 2 Replies Last reply
    0
    • G giddy_guitarist

      hi , well thats what JIT says everytime i run an sql server 05 express sample on my pc.Somehow the code that i write for the dbs i've made runs fine. But every sample ive got , including samples from MSDN give me that error. "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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)" Could someone perhaps tell me how to enable remote connections!? I'm quite a newbie with sqlserver. thanks Gideon

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      giddy_guitarist wrote:

      well thats what JIT says everytime i run an sql server 05 express sample on my pc

      If you refer to the SQL Server using some form of network naming convention it will attempt to connect with TCP/IP which is, for security, turned off by default. e.g. The connection string says: Server=localhost it will attempt to connect via IP address 127.0.0.1 (the loopback adapter) Try Server=(local) as that will attempt to use a (I think) shared memory connection which doesn't go through any network adapter.


      Upcoming events: * Glasgow: Geek Dinner (5th March) * Edinburgh: Web Security Conference Day for Windows Developers (12th April) My: Website | Blog | Photos

      1 Reply Last reply
      0
      • G giddy_guitarist

        hi , well thats what JIT says everytime i run an sql server 05 express sample on my pc.Somehow the code that i write for the dbs i've made runs fine. But every sample ive got , including samples from MSDN give me that error. "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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)" Could someone perhaps tell me how to enable remote connections!? I'm quite a newbie with sqlserver. thanks Gideon

        A Offline
        A Offline
        andyharman
        wrote on last edited by
        #3

        Take a look at SQL-Server's "Surface Area Configuration" tool. By default SQL-Server 2005 doesn't allow connections from remote machines. You need to explitely change this setting.

        C G 2 Replies Last reply
        0
        • A andyharman

          Take a look at SQL-Server's "Surface Area Configuration" tool. By default SQL-Server 2005 doesn't allow connections from remote machines. You need to explitely change this setting.

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          He says he is running "an sql server 05 express sample on my [his] pc". Thus he does not need to open anything to the outside world as all parts are running on the one PC. The question appears to be a false lead, driven by the error message.


          Upcoming events: * Glasgow: Geek Dinner (5th March) * Edinburgh: Web Security Conference Day for Windows Developers (12th April) My: Website | Blog | Photos

          1 Reply Last reply
          0
          • A andyharman

            Take a look at SQL-Server's "Surface Area Configuration" tool. By default SQL-Server 2005 doesn't allow connections from remote machines. You need to explitely change this setting.

            G Offline
            G Offline
            giddy_guitarist
            wrote on last edited by
            #5

            hi , This is the error: http://gidsfiles.googlepages.com/sql_conn_error.jpg[^] Heres my SAC: http://gidsfiles.googlepages.com/sql_sac.jpg[^] I started it for the first time today and thats how it was.I did'nt fiddle with anything there. I did however fiddle with this(still nothing) http://gidsfiles.googlepages.com/sql_cmpman_Settings.jpg[^] This is the connection string in the config file: connectionString="Data Source=ONTEORA-PH0OA8I;Initial Catalog=Northwind;Integrated Security=True" I added Server=localhost and Server=(local). Nothing. Heres the compiled sample+source itself! X| http://gidsfiles.googlepages.com/CodeCampPaintCell.zip[^] I'm sure i have the northwind Db on my pc, and furthermore , i dont have any network of local computers at all! Basically , i'm worried about this because , i'm afraid of having the same problems if i put my Db and app on some other computer.

            C 1 Reply Last reply
            0
            • G giddy_guitarist

              hi , This is the error: http://gidsfiles.googlepages.com/sql_conn_error.jpg[^] Heres my SAC: http://gidsfiles.googlepages.com/sql_sac.jpg[^] I started it for the first time today and thats how it was.I did'nt fiddle with anything there. I did however fiddle with this(still nothing) http://gidsfiles.googlepages.com/sql_cmpman_Settings.jpg[^] This is the connection string in the config file: connectionString="Data Source=ONTEORA-PH0OA8I;Initial Catalog=Northwind;Integrated Security=True" I added Server=localhost and Server=(local). Nothing. Heres the compiled sample+source itself! X| http://gidsfiles.googlepages.com/CodeCampPaintCell.zip[^] I'm sure i have the northwind Db on my pc, and furthermore , i dont have any network of local computers at all! Basically , i'm worried about this because , i'm afraid of having the same problems if i put my Db and app on some other computer.

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              giddy_guitarist wrote:

              This is the connection string in the config file: connectionString="Data Source=ONTEORA-PH0OA8I;Initial Catalog=Northwind;Integrated Security=True" I added Server=localhost and Server=(local). Nothing.

              Data Source and Server are synonyms. Pick either Data Source or Server and stick with it. I suspect Data Source trumps Server, and because you are referring to your PC by name it is attempting to use a network connection.


              Upcoming events: * Glasgow: Geek Dinner (5th March) * Edinburgh: Web Security Conference Day for Windows Developers (12th April) My: Website | Blog | Photos

              G 1 Reply Last reply
              0
              • C Colin Angus Mackay

                giddy_guitarist wrote:

                This is the connection string in the config file: connectionString="Data Source=ONTEORA-PH0OA8I;Initial Catalog=Northwind;Integrated Security=True" I added Server=localhost and Server=(local). Nothing.

                Data Source and Server are synonyms. Pick either Data Source or Server and stick with it. I suspect Data Source trumps Server, and because you are referring to your PC by name it is attempting to use a network connection.


                Upcoming events: * Glasgow: Geek Dinner (5th March) * Edinburgh: Web Security Conference Day for Windows Developers (12th April) My: Website | Blog | Photos

                G Offline
                G Offline
                giddy_guitarist
                wrote on last edited by
                #7

                i got the sample working. Could you just help me out with the following: I now need a connection string that loads a database thats in the same directory as the .dll , .exe When i connect to my database in the server explorer and check the property window , the connection string reads:Data Source=.\SQLEXPRESS;AttachDbFilename="E:\Gid\Hotel Management Studio\HotelManager.Core\DataServices\HTLDATA.mdf";Integrated Security=True;User Instance=True Now , if i use this in SqlConnection() it works fine. Now if i change AttachDbFilename=HTLDATA.mdf. . .and then copy the .exe and the DB into another location . .it doesnt work saying "A dbase with the same name exists or the file cant be open" . So i cant copy my database and use it on the same pc? but then VS itself copies my database from the Project folder into the bin. I found this site:http://www.connectionstrings.com/?carrier=sqlserver2005 The last section has .NET connection strings , i tried: Attach a database file on connect to a local SQL Server Express instance Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname;Trusted_Connection=Yes; But this doesnt work too. Whats dbname? I tried HTLDATA(.mdf) What sring should i use?

                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