Unable to connect to remote SQL Server 2005
I have created my asp.net website using database ASPNETDB.MDF but when I try to host my site on server ...
The SQL Server 2005 hosting provider issue me the
database name dobriyalji
server ip : 69.112.222.220
database username : XXXX
database password : XXXX
I have imported all of my ASPNETDB.MDF tables to my server database dobriyalji ...
And I empty the Appdata.mdf and aspnetdb.log file from App_Data Folder ...
When I try to run my site the following error occurs ...
An attempt to attach an auto-named database for file Users\Ashish Dobriyal\Documents\Visual Studio 2008\WebSites\VOLVO\App_Data\ASPNETDB.MDF
failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
MY LOCALHOST CONN开发者_开发技巧ECTION STRING :
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
MY REMOTE HOST CONNECTION STRING :
<connectionStrings>
<add name="vbi_india2kConnectionString" connectionString="Data Source=69.112.222.220;Initial Catalog=dobriyalji;Persist Security Info=True;User ID=XXXX;Password=XXXX" providerName="System.Data.SqlClient"/>
</connectionStrings>
You have to use publish database wizard to deploy local database to your production database server.
Do you have the physical mdf / ldf files from your development machine. Assuming you do as the error "specified file cannot be opened" is quite clear. So are you on a shared SQL Server with other sites; if so is there a database on the sql server called aspnetdb? You may have to change the name of your database as you attach it in order to get it onto the sql server.
EXEC sp_attach_db @dbname = N'myASPNetDB',
@filename1 = N'c:\mypathdata\myaspnet.mdf',
@filename2 = N'c:\mypathlogs\myaspnet_log.ldf'
精彩评论