entity data connection string problem

Discussion in 'Databases' started by cheddar, May 30, 2011.

  1. This is my first site and I've encountered an error connecting with a SQL 2008 database. Written in .net 4.0 Visual Studio 2010

    Here is the error message:

    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.

    Exception Details: System.Data.SqlClient.SqlException: 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)

    Support told me that the following connection string could be the problem. It is the string that is created for the entity data model and the underlying SQL database. Because of that, it is not formed like a normal connection string. Anyone had this problem before?

    connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider
    connection string='Data Source=tcp:s05.Winhost.com;Initial Catalog=DB_25016_safehaven1;User ID=DB_25016_safehaven1_user;Password=XXXX;Integrated Security=False;'" />

    Would appreciate any suggestions.
     
    Last edited by a moderator: Oct 14, 2015
  2. I edited your post as you included a password in the connection string. If this was an actual password, please change your password immediately.

    Can you post the entire thing? I dont want to assume anything.
     
  3. no password

    The password was removed and placeholders put there, instead as I thought the string should show the basic structure of the connection string. Thanks for looking out for us...I should have mentioned that.
     
  4. Can you paste the entire error and the entire connectionString portion of your web.config?
     
  5. Usually the error message will include the instance name it cant find, i.e. ApplicationServices or whatever

    First things first though, you havent defined a providerName. The correct format would be something like:

    <connectionStrings>
    <add name="InstanceName" connectionString="Data Source=tcp:server.Winhost.com;Initial Catalog=databasename;User ID=db_user;Password=xxxxxx;" providerName="System.Data.SqlClient"/>
    </connectionStrings>
     
    Last edited by a moderator: Oct 14, 2015
  6. I added the " providerName=System.Data.SqlClient" to the connection strings throughout the system. Still got an error, but a smaller one...it's attached.

    Thanks so much for your assistance!

    Cheddar

    View attachment servererror2.pdf
     
  7. Thats the error I was looking for, unfortunately, it doesn't specify the instance name that it cant find. Did you specify System.Data.EntityClient as the provider for the entity model?
     
  8. need to study MSDN article

    Thanks for the reference. Will fix any errors in connection strings and try again. If it fails again (Heaven forbid), will send the win.config and full error.

    Cheddar
     
  9. problem still occurs after connection string rewrite

    rewrote the connection strings as attached and the error message is the same as previously reported.

    Tech support verifies that the databases are not sqlexpress, which is one of the reasons the server error 26 might occur. They point to the code, which I assume is the connection string.

    Still looking for assistance.

    Thanks!
     

    Attached Files:

  10. more info on development platform

    The app was created in VS 2010. One database was created in SQL Server 2008 R2, the other attached successfully from aspnetdb.mdf in app_data folder to provide application security. Both databases connect normally in IIS7 Server Manager and SQL Server 2008 R2 Server Management Studio. I just can't connect programmatically through the ##@@%& connection strings.

    Sorry for the expression of frustration.:eek:
     
  11. Ray

    Ray

    For something like this we'll need the full error message or the URL were we can see the error message. Having a snippet of the code/error can be misleading and start taking us down the wrong path. My guess is you maybe connecting to the database (.mdf file) that is inside the app_data folder. That means you are trying to connect directly to the mdf file. This is not supported because it will require that SQL express be installed on the web server. But this is only a guess base off what we know so far.
     
  12. server error

    The server error is included with this post.

    The aspnetdb.mdf has been attached to the shsecurity database. The hosting plan was upgraded specifically to do this.

    Will appreciate any assistance you can offer.

    Would it be possible to arrange a three-way call to discuss with MS tech support?
     

    Attached Files:

  13. Ray

    Ray

    Why don't you email the URL on how I can replicate this error on my end and what database you are using for the membership/roles provider.
     
  14. Go to http://www.safehavendatasys.org/myapp/UserLogin.aspx and enter anything in name and password and click login button. Error will be produced. File used for membership roles provider is DB_25016_shsecurity.

    Thanks for your assistance.

    BTW, I like your avatar image...very Norse.
     
  15. I will take a look at this later today.
     
  16. Im sorry, to tell you, but I have a feeling that what you posted is different than whats in your web.config on the server. Double check the server name in your connection string for the ApplicationServices connectionString.
     

Share This Page