Solved

No Database connection after uploading site

Posted on 2015-01-26
12
204 Views
Last Modified: 2015-01-27
Using VS 2013, after I ftp the site to the server, there is a problem with the database.  See error message below.
PS: Does it make a difference if I FTP or Publish?


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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
)
  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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
)

Source Error:



Line 22:             ' Validate the user password
Line 23:             Dim manager = New UserManager()
Line 24:             Dim user As ApplicationUser = manager.Find(UserName.Text, Password.Text)
Line 25:             If user IsNot Nothing Then
Line 26:                 IdentityHelper.SignIn(manager, user, RememberMe.Checked)
0
Comment
Question by:rrhandle8
  • 6
  • 5
12 Comments
 
LVL 33

Expert Comment

by:paulmacd
ID: 40571469
"The server was not found or was not accessible."
Well there's your problem.

I take it the database server you have configured prior to pushing up the site should be available once the site is established?  I would double-check that.
0
 

Author Comment

by:rrhandle8
ID: 40571482
The database is there.

Databases.png
0
 

Author Comment

by:rrhandle8
ID: 40571489
Here are the connection strings.

It is the Willowlane database I am trying to use.

The other database is an unknown at this time.  It belongs to a 3rd-party application I will get to later.

 <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WillowLane1-f59c4ece-32dd-40f4-9451-1620648a0486;AttachDbFilename=|DataDirectory|\aspnet-WillowLane1-f59c4ece-32dd-40f4-9451-1620648a0486.mdf;Integrated Security=SSPI"
      providerName="System.Data.SqlClient" />
    <add name="DatabaseConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40571490
what is your sql config setting in the servers web.config
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40571497
(LocalDb)\v11
what does the website provider say about sql connection strings.. do they support localdb?
0
 

Author Comment

by:rrhandle8
ID: 40571571
Just noticed I am using .NET 4.5, but the server has .NET 4.0.  Could that be the problem?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40571676
could be part of it but probably more to do with the sql connection settings
if you publish it to azure does it work?
0
 

Author Comment

by:rrhandle8
ID: 40571828
Don't know. Don't have an account.

website provider says I need to have a separate Web.config file, and use the IP address in place of localdb.  Tried that, but got another error:


Invalid value for key 'attachdbfilename'.
  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.ArgumentException: Invalid value for key 'attachdbfilename'.

Source Error:



Line 12:     Inherits IdentityDbContext(Of ApplicationUser)
Line 13:     Public Sub New()
Line 14:         MyBase.New("DefaultConnection")
Line 15:     End Sub
Line 16: End Class
0
 
LVL 78

Accepted Solution

by:
David Johnson, CD, MVP earned 500 total points
ID: 40571852
you need to add the credentials to your web config and not use Integrated Security=SSPI

i.e. from godaddy
<connectionStrings>

<add name="Personal" connectionString=" Server=whsql-v04.prod.mesa1.secureserver.net; Database=DB_675; User ID=user_id; Password=password; Trusted_Connection=False" providerName="System.Data.SqlClient" /> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString=" Server=whsql-v04.prod.mesa1.secureserver.net; Database=DB_675; User ID=user_id; Password=password; Trusted_Connection=False" providerName="System.Data.SqlClient" />

</connectionStrings>
0
 

Author Comment

by:rrhandle8
ID: 40571879
So I will need to maintain two separate web.config files?
BTW: When I created the database, I used Visual Studio 2013 to create it.  It never asked me for a username and password.  I am use to connecting to a database on the server.  First time I ever used VS to create the database.  How can I assign a username and password to the database?
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40572009
you have to maintain 2 web.config 1 for local and 1 for on the webserver (since you don't control it)
0
 

Author Comment

by:rrhandle8
ID: 40572405
Thanks, David. You got me past the error. Unfortunately, my login attempts are failing.

In the example you sent, I see you are removing LocalSqlServer, then adding it back. The connection string Personal and LocalSqlServer are both the same. Could you be so kind as to explain that, or send me to an explanation on-line?


<add name="Personal" connectionString=" Server=whsql-v04.prod.mesa1.secureserver.net; Database=DB_675; User ID=user_id; Password=password; Trusted_Connection=False" providerName="System.Data.SqlClient" /> <remove name="LocalSqlServer"/> <add name="LocalSqlServer" connectionString=" Server=whsql-v04.prod.mesa1.secureserver.net; Database=DB_675; User ID=user_id; Password=password; Trusted_Connection=False" providerName="System.Data.SqlClient" />
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now