locked
SQL Server is NOT configured to allow remote connections.

    Question

  • I get an error on this line:

    int returnValue = this .Adapter.Fill(dataTable);

    Error mssg reads: ‘A network-related or instance-specific error occurred while establishing 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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)’

    Do I need to change some setting on my SQL Server or do I need to changesomething in my C# code?

    I think the poroblem is in here:

            [global ::System.Diagnostics.DebuggerNonUserCodeAttribute ()]

            [global ::System.ComponentModel.Design.HelpKeywordAttribute ("vs.data.TableAdapter" )]

            [global ::System.ComponentModel.DataObjectMethodAttribute (global ::System.ComponentModel.DataObjectMethodType .Fill, true )]

            public virtual int Fill(ExchangeRatesDataSet .CountriesDataTable dataTable) {

                this .Adapter.SelectCommand = this .CommandCollection[0];

                if ((this .ClearBeforeFill == true )) {

                    dataTable.Clear();

                }

                int returnValue = this .Adapter.Fill(dataTable);

                return returnValue;

            }

    There’s a wholelotta code in this .cs module.  I can’t copy/paste all in here.  The code is from a book about databinding with c#.

     

    Thanks for the help!

    Ryan--

    Thursday, April 29, 2010 1:04 PM

Answers

  • Hello,

    Just a little add-in to the excellent post of Rudedog

    Is it possible for RYGUY72 to post the connection string used for the creation of your SQLConnection ?

    If you have UserInstance = true, suppress the part USERINSTANCE ( it seems according the SQL Server Express Team, that the feature UserInstance should be disappearing with the next version 11 of SQL Server ). Moreover, as RudeDog points it, userinstance is a feature specific to express editions. So it is not a good idea to use it if you know that you may use Standard or Entreprise editions of SQL Server.

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.
    • Marked as answer by ryguy72 Monday, May 03, 2010 5:03 PM
    Sunday, May 02, 2010 7:03 PM
  • That is the package that you need to use with 2008. Didn't you try to open it up?

    You should exercise caution and restraint prior to enabling remote connections.  You appear to be quite new to SQL programming.  It is not the sort of area you should dig into if you require detailed step by step instructions to do anything. 

    SQL Server will require that you be able to "connect the dots" and figure stuff out on your own.  This will be most especially true when you try to define and implement permissions for remote users.  Much may depend upon the details of your network, how many users, and the required access for those users.

    See if this thread helps.

    The connection to the database could not be created

    Rudy  =8^D


    Mark the best replies as answers. "Fooling computers since 1971."
    • Marked as answer by ryguy72 Monday, May 03, 2010 5:03 PM
    Monday, May 03, 2010 12:56 PM

All replies

  • It would be a big help to know which version of SQL you are having trouble with, but most work the same way. 

    SQL Express has remote connections disabled by default.  The Connection Wizards in VS Express does not connect to server instances, only server files.  You must connect to a remote SQL instance in order to connect to remote SQL files.  You must do it in code.

    How to configure SQL Server 2005 to allow remote connections

    There is a lot more to it than that.  Once you are able to log on remotely, then you need to set up the server instance to grant permissions to those authorized users to to actually do stuff.  You will need to specify which database on the instance they should access, which tables, CRUD privileges.

    Logging on to a server is equivalent to turning on your computer and logging on.  Now you want to be able to do something.  You must define and set it all up.

    SQL Express simplifies this process tremendously.  It allows you to connect to a local instance through a mechanism known as a user instance, which is not available on full versions of SQL.  User instances are for local use only.

    Rudy  =8^D


    Mark the best replies as answers. "Fooling computers since 1971."
    • Proposed as answer by Papy Normand Sunday, May 02, 2010 7:03 PM
    Thursday, April 29, 2010 2:55 PM
  • Hello,

    Just a little add-in to the excellent post of Rudedog

    Is it possible for RYGUY72 to post the connection string used for the creation of your SQLConnection ?

    If you have UserInstance = true, suppress the part USERINSTANCE ( it seems according the SQL Server Express Team, that the feature UserInstance should be disappearing with the next version 11 of SQL Server ). Moreover, as RudeDog points it, userinstance is a feature specific to express editions. So it is not a good idea to use it if you know that you may use Standard or Entreprise editions of SQL Server.

    Have a nice day


    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.
    • Marked as answer by ryguy72 Monday, May 03, 2010 5:03 PM
    Sunday, May 02, 2010 7:03 PM
  • Thanks Rudedog2 and Papy!  I'm on SQL Server 2008 Express.  Under Start > All Programs > Microsoft SQL Server 2008, I have ‘Configuration Tools’ and ‘SQL Server Configuration Manager’.  That’s probably the closest thing I can find.  I don’t see anything called ‘Surface Area Configuration for Services and Connections’. 
    Monday, May 03, 2010 5:25 AM
  • That is the package that you need to use with 2008. Didn't you try to open it up?

    You should exercise caution and restraint prior to enabling remote connections.  You appear to be quite new to SQL programming.  It is not the sort of area you should dig into if you require detailed step by step instructions to do anything. 

    SQL Server will require that you be able to "connect the dots" and figure stuff out on your own.  This will be most especially true when you try to define and implement permissions for remote users.  Much may depend upon the details of your network, how many users, and the required access for those users.

    See if this thread helps.

    The connection to the database could not be created

    Rudy  =8^D


    Mark the best replies as answers. "Fooling computers since 1971."
    • Marked as answer by ryguy72 Monday, May 03, 2010 5:03 PM
    Monday, May 03, 2010 12:56 PM