Solved

No Database connection after uploading site

Posted on 2015-01-26
12
226 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 79

Expert Comment

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

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 79

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 79

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 79

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

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.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

832 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