4

I'm attempting to deploy an ASP.NET MVC 4.0 application, and I am using a shared web hosting solution. I am able to successfully deploy everything, except for my preexisting databases, one for user accounts, and one for posts.

These two databases are in the App_Data directory of my application.

Every part of the application requiring database communication returns the following:

Invalid value for key 'attachdbfilename'

I should note that this problem does NOT occur when testing locally.

My web hosting provider has created a SQL Server database, providing me with a server IP, a username/database name, and a password. However I'm unsure how I can access it, and then replicate the current database in my application in the database on my web host.

Basically my question is, how do I get my SQL Server databases to work on my web hosting?

1
  • That AttachDbFileName=... feature is available in the Express edition only and most likely, your web hoster doesn't use the Express edition for its hosting. Commented Sep 13, 2013 at 18:19

1 Answer 1

4

In this scenario you should not attach your own DB files. Create a new database (e.g. using SSMS or host's Control Panel) on the server provided by the host. Import your local data into that DB and use new server/db/uid/password in your connection string.

If your host already provided you the DB - just use existing DB (don't create a new one) but still import your local data into that DB.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your answer, would you be able to tell me how I'd go about importing the data into the database? Like I said, I have the IP, name, and password, but I'm not sure how to use them when updating a database.
Can you access that remote DB via Sql Server Management Studio by IP?
The IP they provided is like this XX.XX.X.X (X being a number), I entered this into the 'Connect to server box', with the server type set to 'Database engine', authentication set to 'SQL server authentication', and then entered the provided username and password. I receive an error saying that the server cannot be found.
That could mean server cannot be accessed directly from outside of host's network. Or perhaps it is using a different port. I think you should contact host's support, explaining that you need to import your existing DB and asking what's the best way would be in their environment. They may have an established process.
Tagging onto @YuriyGalanter 's comment - Been there myself many times before. SQL Server on Shared hosting is notoriously screwy as it seems each web host has their own individual set of rules of not only how they set everything up but how you access it as well. It's got nothing to do with the product but the hosting companies policies. Contact your web hosting support desk to get the exact protocol on how you should connect to the your db server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.