Sql 2008 R2: connection problems

Discussion in 'Databases' started by nathan, Jun 25, 2013.

  1. Hi All,

    I'm setting up a new site and the database connection(s) work fine when I run the site on my local machine (connecting from my local machine to the live database - yes, bad, but still testing etc). When I deploy (with the exact same connection strings) to the live servers (have a look here), I get the error below.

    Any help would be much appeciated :cool:

    Server Error in '/' Application.

    The system cannot find the file 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.

    Exception Details: System.ComponentModel.Win32Exception: The system cannot find the file specified

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [Win32Exception (0x80004005): The system cannot find the file specified]

    [SqlException (0x80131904): 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)]
    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5296071
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +558
    System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover) +5308555
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover) +145
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout) +889
    System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance) +307
    System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions) +434
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +225
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +37
    System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions) +558
     
  2. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    It looks like you may be trying to use a SQL Server Express database which is not supported in a production environment.
     
  3. Thanks for your reply. :)

    However, my code connects ok from my local machine to the live database server... this error only happens when I publish to the production [discountasp.net] server. (which makes me think that the type of database I'm connecting to isn't likely to be the problem [happy to be corrected of course]... I'll post my connection strings tomorrow if no other ideas come up between now and then :eek:)
     
  4. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Yes, could you post the connection strings?
     
  5. Connection Strings

    On the discountasp.net server, #1 is failing and #2 is working (Note: because #1 fails, I can't get far enough into the site to determine if 3 and 4 are working or not). However, they all work from my local machine.

    1. <add name="MembershipConnection" connectionString="Data Source=esql2k804.discountasp.net;DataBase=SQL2008R2_925406_abdnjudo;Persist Security Info=False;User ID=<admin_username>;Password=<pwd>;" providerName="System.Data.SqlClient" />
    2. <add name="public" connectionString="metadata=res://*/DataBase.AJC.csdl|res://*/DataBase.AJC.ssdl|res://*/DataBase.AJC.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=esql2k804.discountasp.net;DataBase=SQL2008R2_925406_abdnjudo;Persist Security Info=False;User ID=<public_web_username>;Password=<pwd>;multipleactiveresultsets=True;App=EntityFramework&quot;" />
    3. <add name="member" connectionString="metadata=res://*/DataBase.AJC.csdl|res://*/DataBase.AJC.ssdl|res://*/DataBase.AJC.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=esql2k804.discountasp.net;DataBase=SQL2008R2_925406_abdnjudo;Persist Security Info=False;User ID=<club_member_username>;Password=<pwd>;multipleactiveresultsets=True;App=EntityFramework&quot;" />
    4. <add name="admin" connectionString="metadata=res://*/DataBase.AJC.csdl|res://*/DataBase.AJC.ssdl|res://*/DataBase.AJC.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=esql2k804.discountasp.net;DataBase=SQL2008R2_925406_abdnjudo;Persist Security Info=False;User ID=<admin_username>;Password=<pwd>;multipleactiveresultsets=True;App=EntityFramework&quot;" />

    note: bb code is mangling "multipleactiveresultsets=True" and "DataBase=SQL2008R2_925406_abdnjudo" and putting a space in for some reason - those spaces aren't in the connection strings
     
  6. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Code:
    &quot;
    should be a literal double quote in the connection string.

    Code:
    "
     
  7. the
    Code:
    &quot;
    is in the connection string which works (and that's just encoded like that because it's xml)

    If it were a malformed connection string, then I would expect it to break on my local machine too.... :confused:
     
  8. I've managed to figure this out: a combination of this and missing correct role provider configuration was causing the problem. Thanks for looking though :)
     
  9. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Glad you were able to solve the problem. :)
     

Share This Page