Zatos
Zatos

Reputation: 329

Publishing VS website project to Godaddy - SQL Server database connection issues

I've got a website project that I'm working on, and I'm having a hell of a time trying to figure out how to get my database to work after publishing to GoDaddy, but it works locally. I haven't built a project before, so this is new to me. I figured out that my first problem was that I was using LocalDB, and that is local only (despite some claims that you can rig it otherwise, none worked for me though).

First of all, I'm using the Adventure Works 2012 database locally, and uploading it with the project on publish. Maybe this is my first problem?

From the web.config:

<add name="AdventureWorks2012_DataEntities" 
     connectionString="metadata=res://*/Models.Entities.csdl|res://*/Models.Entities.ssdl|res://*/Models.Entities.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\AdventureWorks2012_Data.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework;User Instance=True&quot;" 
     providerName="System.Data.EntityClient" />

And the connection string in GoDaddy asp.net settings:

AdventureWorks2012_DataEntities
metadata=res://*/Models.Entities.csdl|res://*/Models.Entities.ssdl|res://*/Models.Entities.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\AdventureWorks2012_Data.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework;User Instance=True"

I currently get the error:

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)

I don't know if that connection string can even possibly work when published (as in needs an actual network location with username/password)? There are databases you can configure on GoDaddy, and maybe I have to do it that way - assuming I could get my data into that database that way. The only way I can see of doing it is maybe dumping the table data to sql scripts and running them from the MyLittleAdmin tool. But I'm not sure still how I'd configure it to work even if I got the data in there. Plus, it seems the features are extremely limited with the MyLittleAdmin tool. Also the database in my local files is in a SQL Server 2016 Express version format, although I can change that - I don't know if that is part of the problem or not in regards to GoDaddy.

I really wanted to figure this out on my own, but I've been going in circles for days. I don't know if I'm just missing something or if I'm going about this all wrong. Or if there is more to it and that I'll need to find another hosting provider other than GoDaddy, as I've read some mentions about how they suck in this regard with SQL Server databases.

I really appreciate any help someone can shine on this.

Upvotes: 0

Views: 380

Answers (1)

Jimmy
Jimmy

Reputation: 28376

The issue is most likely that your connection string is pointing at the local machine (web server) looking for a SQL Express instance. Extracted from the larger connection string:

data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\AdventureWorks2012_Data.mdf;integrated security=True;...;User Instance=True"

If you have a SQL server provided by GoDaddy, you need to publish your SQL database there, and then have your connection string converted to point at that server when the site is published.

Upvotes: 1

Related Questions