使用连接字符串连接到提供程序的 SQL Server 2008
我刚刚将我的网站部署在提供商 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>
有人可以告诉我如何修改它吗?
I just deployed my website on a remote server of the provider somee.com
, but I can't manage to connect to my SQL Server database.
I attached the *.mdf and *.ldf files to the database I created on the provider side, which asked me to update my connection string with this (I concealed the id and password of course):
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
Now, I know I have to update my Web.config file, but I just don't have a clue where to add these properties to my original tag:
<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>
Could someone please tell how to modify it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道你发布的所有实体内容。但是现在您已经将数据库附加到主机上,您不再需要有关 AttachDBFileName、用户实例等的任何信息。对于应用程序,它看起来像这样(为了可读性添加了回车符):
其他人将必须翻译该实体/model 连接字符串。
I have no idea about all the entity stuff you posted or. But now that you've attached your database at a host, you no longer need anything about AttachDBFileName, user instances, etc. For the application it would look like this (carriage returns added for readability):
Someone else will have to translate the entity/model connection strings.
你还需要把这个。;
<默认文档>
<文件>
<添加值=“index.aspx”/>
Also you need to put this.
<system.webServer>
<defaultDocument>
<files>
<add value="index.aspx" />
</files>
</defaultDocument>
</system.webServer>