我刚刚在提供商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
现在,我知道我必须更新我的网页。配置文件,但我只是不知道在哪里添加这些属性到我的原始标签:
<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>
谁能告诉我怎么修改它?
我不知道所有的实体的东西你张贴或。但是现在您已经在主机上附加了数据库,您不再需要关于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>
其他人必须翻译实体/模型连接字符串
你还需要把这个。<system.webServer>
<defaultDocument>
<files>
<add value="index.aspx" />
</files>
</defaultDocument>
</system.webServer>