使用连接字符串连接到提供程序的 SQL Server 2008

发布于 2024-12-04 05:50:23 字数 4503 浏览 0 评论 0原文

我刚刚将我的网站部署在提供商 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=&quot;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated 
Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" 
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=&quot;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated 
Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" 
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=&quot;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated 
Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" 
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=&quot;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated 
Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" 
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=&quot;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated 
Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" 
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=&quot;AttachDbFilename=|DataDirectory|\MoviesDB.mdf;Integrated 
Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" 
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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

红墙和绿瓦 2024-12-11 05:50:24

我不知道你发布的所有实体内容。但是现在您已经将数据库附加到主机上,您不再需要有关 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>

其他人将必须翻译该实体/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):

<connectionStrings>
    <add name="ApplicationServices"
     connectionString="user id=dalya;pwd=02038800;
      data source=MoviesDBtest.mssql.somee.com;
      initial catalog=MoviesDBtest;"
      providerName="System.Data.SqlClient" />
</connectionStrings>

Someone else will have to translate the entity/model connection strings.

岁月无声 2024-12-11 05:50:24

你还需要把这个。;
<默认文档>
<文件>
<添加值=“index.aspx”/>



Also you need to put this.<system.webServer>
<defaultDocument>
<files>
<add value="index.aspx" />
</files>
</defaultDocument>
</system.webServer>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文