我刚刚将我的网站部署在提供商somee.com
的远程服务器上,但我无法连接到我的SQL Server数据库。
我将* .mdf和* .ldf文件附加到我在提供者端创建的数据库,它要求我用这个更新我的连接字符串(当然我隐藏了id和密码):
workstation id=MoviesDBtest.mssql.somee.com;packet size=4096;user
id=xxxxx;pwd=xxxxxxxx;data source=MoviesDBtest.mssql.somee.com;persist security
info=False;initial catalog=MoviesDBtest
现在,我知道我必须更新我的Web.config文件,但我不知道将这些属性添加到原始标记的位置:
<connectionStrings>
<add name="ApplicationServices" connectionString="workstation
ID=MoviesDBtest.mssql.somee.com;packet size=4096;user id=dalya;pwd=02038800;data
source=MoviesDBtest.mssql.somee.com;persist security info=False;initial
catalog=MoviesDBtest;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" /><add name="MovieDBEntities"
connectionString="workstation ID=MoviesDBtest.mssql.somee.com;packet size=4096;user
id=dalya;pwd=02038800;data source=MoviesDBtest.mssql.somee.com;persist security
info=False;initialcatalog=MoviesDBtest;metadata=res://*/Models.MoviesDBModel.csdl|res://*/M
odels.MoviesDBMode
l.ssdl|res://*/Models.MoviesDBModel.msl;provider=System.Data.SqlClient;provider
connection string="AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated
Security=True;User Instance=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" /><add name="MoviesDBEntities"
connectionString="workstation ID=MoviesDBtest.mssql.somee.com;packet size=4096;user
id=dalya;pwd=02038800;data source=MoviesDBtest.mssql.somee.com;persist security
info=False;initial
catalog=MoviesDBtest;metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://
*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection
string="AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated
Security=True;User Instance=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" /><add name="MoviesDataBEntities"
connectionString="workstation ID=MoviesDBtest.mssql.somee.com;packet size=4096;user
id=dalya;pwd=02038800;data source=MoviesDBtest.mssql.somee.com;persist security
info=False;initial
catalog=MoviesDBtest;metadata=res://*/Models.MoviesDBModel.csdl|res://*/Models.MoviesDBMode
l.ssdl|res://*/Models.MoviesDBModel.msl;provider=System.Data.SqlClient;provider
connection string="AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated
Security=True;User Instance=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" /><add name="WTFEntities"
connectionString="workstation ID=MoviesDBtest.mssql.somee.com;packet size=4096;user
id=dalya;pwd=02038800;data source=MoviesDBtest.mssql.somee.com;persist security
info=False;initial
catalog=MoviesDBtest;metadata=res://*/Models.MoviesDBModel.csdl|res://*/Models.MoviesDBMode
l.ssdl|res://*/Models.MoviesDBModel.msl;provider=System.Data.SqlClient;provider
connection string="AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated
Security=True;User Instance=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" /><add name="MovieDBEntities"
connectionString="workstation ID=MoviesDBtest.mssql.somee.com;packet size=4096;user
id=dalya;pwd=02038800;data source=MoviesDBtest.mssql.somee.com;persist security
info=False;initial
catalog=MoviesDBtest;metadata=res://*/Models.MoviesDBModel.csdl|res://*/Models.MoviesDBMode
l.ssdl|res://*/Models.MoviesDBModel.msl;provider=System.Data.SqlClient;provider
connection string="AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated
Security=True;User Instance=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" /><add name="MoviesDBEntities1"
connectionString="workstation ID=MoviesDBtest.mssql.somee.com;packet size=4096;user
id=dalya;pwd=02038800;data source=MoviesDBtest.mssql.somee.com;persist security
info=False;initial
catalog=MoviesDBtest;metadata=res://*/Models.MoviesDBModel.csdl|res://*/Models.MoviesDBMode
l.ssdl|res://*/Models.MoviesDBModel.msl;provider=System.Data.SqlClient;provider
connection string="AttachDbFilename=|DataDirectory|\MoviesDB.mdf;Integrated
Security=True;User Instance=True;MultipleActiveResultSets=True""
providerName="System.Data.EntityClient" /></connectionStrings>
有人可以告诉我们如何修改它吗?
答案 0 :(得分:5)
我不知道您发布的所有实体内容或。但是现在您已经在主机上附加了数据库,您不再需要任何有关AttachDBFileName,用户实例等的内容。对于应用程序,它看起来像这样(为了可读性而添加了回车符):
<connectionStrings>
<add name="ApplicationServices"
connectionString="user id=dalya;pwd=02038800;
data source=MoviesDBtest.mssql.somee.com;
initial catalog=MoviesDBtest;"
providerName="System.Data.SqlClient" />
</connectionStrings>
其他人必须翻译实体/模型连接字符串。
答案 1 :(得分:0)
另外你需要把它。<system.webServer>
<defaultDocument>
<files>
<add value="index.aspx" />
</files>
</defaultDocument>
</system.webServer>