Solved

No Database connection after uploading site

Posted on 2015-01-26
12
229 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 34

Expert Comment

by:Paul MacDonald
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 80

Expert Comment

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

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
 
LVL 80

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 80

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 80

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

792 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