Solved

No Database connection after uploading site

Posted on 2015-01-26
12
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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