[newbie]

  • When I run code Listing 16-3, I am getting the following error:

    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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    So far I have tried the following, after re-installing SQL Server 2005 Express Edition:

    1. Starting up SQL Server browser and checking that remote connections is allowed. Firewall is disabled.

    (URL: http://www.mydigitallife.info/2007/10/31/error-has-occurred-while-establishing-a-connection-to-sql-server-2005-which-does-not-allow-local-and-remote-connections/)

    2. Installed SQL Server SP2. It's noted that some of the features could not be reinstalled.

    3. Run C:\Windows\Microsoft .NET\Framework\v2.0.50727\aspnet_regsql.exe. It is important to update servername\INSTANCENAME within the wizard (e.g. mine is dev01\JOEY.)

    By any chance does the within the web.config file

    have to be modified. It currently reads:

    ...

    connectionStringName="LocalSqlServer"

    ...

    Within SQL Server Configuration Manager:

    SQL Server 2005 Network Configuration Manager > Protocols for $INSTANCENAME

    Shared Memory - Enabled

    Named Pipes - Enabled

    TCP/IP - Enabled

    VIA - Disabled

    SQL Native Client Configuration > Client Protocols

    Shared Memory - Enabled

    TCP/IP - Enabled

    Named Pipes - Enabled

    VIA - Disabled

  • Can you post the actual connection string instead of the name of the connection string?

    Yesterday I answered a similar question and the individual was not using the instance name in the connection string. Your Data Source or Server attribute needs to be ServerName\InstanceName and when you use the defaults when installing SQL Server Express the instance name is SQLExpress.

  • I would like to give you the required connection string, however, I'm not sure how to go about it, so specific questions would be appreciated.

    Basically I'm using ASP.NET membership (following a tutorial) and, it should use the connectionString within the web.config for the database connection.

  • Since it doesn't appear that you will be giving away any sensitive information, why don't you make a copy of the web.config file, rename it to web.txt and attach it to the thread.

  • Attached web.config.

  • Jon,

    You actually do not have a connection string created in the web.config. You need to replace this:

    <connectionStrings/>

    With

    <connectionStrings>

    <connectionString name="LocalDB" value="Data Source=servername\instancename;Initial Catalog=DataBase;User Id=myUsername;Password=myPassword;

    <connectionStrings/>

    You can go to http://connectionstrings.com for various connection strings and syntax.

  • Thanks. Tried a couple of connection strings, but I probably need to dig memberships (ASP.NET) because they are not being accepted, for example:

    web.config

    ...

    connectionStringName="Data Source=DEV01\JOEY;User ID=sa; Password=password;"

    ...

    Returns this error:

    The connection name 'Data Source=DEV01\JOEY;User ID=sa; Password=password;' was not found in the applications configuration or the connection string is empty.

  • Jon,

    You did not put the connection string in the web.config file correctly. Just copy and paste what i posted and then change what needs to be changed.

  • Well the actual syntax should be slightly different according to my book:

    As expected the connection string using the user name and password did not work; in fact I cannot connect from SMSE even using sa.

    I also tried connecting remotely from another machine by creating a connection from Visual Studio 2008 from the Connection wizard. Using VS2008 (SQLClient) from another machine, this is the behavior I see:

    Trying to logon using Windows Authentication returns:

    Login failed for user ". The user is not associated with a trusted SQL connection.

    There is some problem with the "trust", maybe I need to configure it.

    Trying to logon using sa is unsuccessful; created another user and logged on successfully, so the remote connection between both machines is fine; however

    the default 'sa' account cannot be used within

    When I run the application I am getting the same error in any case:

    A network-related or instance-specific error occurred...

    :w00t:

    Related links:

    1. http://weblogs.asp.net/achang/archive/2004/04/15/113866.aspx

    - How to use Trusted Connection when SQL server and web Server are on two separate machines.

    "you just need to make sure the local “ASPNET” account (under which ASP.NET application runs) has appropriate access to the database that your application will be using." ...what rights?

    There seems to be no ASPNET account only an Administrator account on my machine (because I have installed it that way).

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply