使用托管的Web应用程序连接到SQL Server数据库 [英] Connecting to SQL Server Database using a Hosted Web Application
问题描述
我已经使用c#创建了一个.net Web应用程序,该应用程序可以从SQL Server数据库中插入,更新和删除数据。我已经使用本地主机对其进行了测试,并且工作正常。现在,我想将此应用程序发布在托管站点上。
I have created a .net web application using c# that inserts, updates, and deletes data from an SQL server database. I have tested it using my localhost and it works fine. Now I would like to publish this application on a hosted site.
我的问题是,数据库是否需要与应用程序所在的同一服务器/主机上
有没有人提示如何实现此目的?
My question is, does the database need to be on the same server/host that the application is in for it to connect?
Does anyone have any tips on how to implement this?
推荐答案
如果您有问题是如何连接另一台服务器上存在的数据库,则必须在Web.config文件中将其IP地址添加为:
If your Question is 'How to connect database present on another server', then you have to Add IP address of it in the Web.config file as:
<connectionStrings>
<add name="myConnectionString" connectionString="data source=myserver\SQLEXPRESS;initial catalog=myDatabase;uid=myUserName;password=myPassword;" />
</connectionStrings>
数据源
可以是IP地址或PC NAME,即数据库的存储位置。
data source
can be IP ADDRESS or PC NAME, where Database is stored.
这篇关于使用托管的Web应用程序连接到SQL Server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!