一个托管在本地但在远程数据库上的网站我如何访问数据库 [英] A website which is hosted on local but database on remote how i can access The database

查看:87
本文介绍了一个托管在本地但在远程数据库上的网站我如何访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用c#在asp.net 3.5中开发的网站。我在本地主机上托管此站点,而SQL Server在本地服务器上。我无法使用sql server连接网站。请帮我解决这个问题



Thanx关于

Ankush

解决方案

< blockquote>令人敬畏的MSDN文章供您开始使用。



ASP.NET Web应用程序的SQL Server连接字符串 [ ^ ]。


供您参考..



ASP.NET就是这样做的不区分本地和远程数据库服务器。你可能想要照顾的事情是



1.让连接字符串指向数据库服务器使用其IP地址和端口



2.由于无法使用集成安全性,因此还需要用户名和密码才能访问数据库。如果Web服务器和数据库服务器都在单个网络域信任下运行,则可以使用集成安全性。



3.确保用于访问数据库的端口是为您的Web服务器的防火墙中的出站流量打开



您需要注意的真实事情是服务器名称/ IP地址:服务器的端口 - 所以,您的Web.config连接字符串应如下所示:



 <   connectionStrings  >  
< add name = MyConnectionString connectionString = 数据源= SERVER-IP:PORT;数据库= DBName;用户名=< user> ;;密码=<传递> < span class =code-attribute> providerName = System.Data.SqlClient / >
< / connectionStrings >







关于连接字符串的更多内容 http://www.connectionstrings.com/ [ ^ ]


首先需要授予sql数据库访问远程的权限,以及用于ConnectionString的网站webconfig和datasource =远程的ip地址系统/服务器名称>


I have a website which is developed in asp.net 3.5 with c#. i am host this site on local host and sql server is on Local Server. I am not able to connect website with sql server. please help me to solve that problem

Thanx with regards
Ankush

解决方案

Awesome MSDN article for you to get started.

SQL Server Connection Strings for ASP.NET Web Applications[^].


for your reference..

ASP.NET as such does not differentiate local and remote database servers. The things you might want to take care though are

1. Have the connection string point to the database serverusing its IP address and port

2. You also need a user name and password to access the database since the Integrated Security cannot be used. You can use integrated security if both the web server and database server are running under a single network domain trust.

3. Ensure that the port used to access the database is opened for Outbound traffic in your web server's firewall

The real thing you have to pay attention on it is the SERVER NAME / IP ADDRESS : PORT of the server - so, your Web.config connection string should look like the following:

<connectionStrings>
  <add name="MyConnectionString" connectionString="Data Source=SERVER-IP:PORT;Database=DBName;User Name=<user>;Password=<pass>" providerName="System.Data.SqlClient" />
</connectionStrings>




more on connection strings is here http://www.connectionstrings.com/[^]


firstly you need to grant permission on sql database to access it to remote and the website webconfig used to ConnectionString with datasource="ip address of remote system/server name">


这篇关于一个托管在本地但在远程数据库上的网站我如何访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆