网站无法与sql server通信。 [英] Website not able to communicate with sql server.

查看:76
本文介绍了网站无法与sql server通信。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个asp.net网站并将其部署在本地IIS上。

每当我尝试在本地机器上浏览它时,它运行正常。



但每当我尝试从其他机器打开它时就会出现问题。客户端无法连接到我的本地sql server管理2008 R2。





我不知道是什么原因。但是要通知你:



我用.cs文件返回连接我的网站中的字符串。

我没有使用webconfig。



I made an asp.net WEBSITE and has deployed it on local IIS .
whenever i try to browse it in local machine,it works fine.

But whenever i try to open it from other machines.It gives problem.The client is not able to connect to my local sql server management 2008 R2.


I dont know what is the reason.But to notify you:

I used a .cs file that returns the connection string in my website.
I did not use thw webconfig for that.

public class ConString
{
	public ConString()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static string ConnectionDetails()
    {
        return ("Data Source=.;Initial Catalog=TrackerDb;Integrated Security=False;User Id=sa;Password=#welcome123");
    }
}

推荐答案

连接字符串包含数据源=。,其中。当你在本地运行时,操作员选择你当地的默认SQL Server。



但是当你从其他机器运行网站时,你需要连接到你的IP而不是。。



为此你的连接字符串将遵循以下格式。

The connection string contains Data Source=., in which "." operator selects the default SQL Server in your local, when you are running at the local end.

But when you run the website from other machine, you need to connect to your IP instead of ".".

For that your connection string will follow the below formats.
标准安全



Server = myServerAddress; Database = myDataBase; User Id = myUsername; Password = myPassword;





可信连接



Server = myServerAddress; Database = myDataBase; Trusted_Connection = True;





与SQL Server实例的连接

服务器选项中使用的服务器/实例名称语法对于所有SQL Server连接字符串都是相同的。



Standard Security

Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;


Trusted Connection

Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;


Connection to a SQL Server instance
The server/instance name syntax used in the server option is the same for all SQL Server connection strings.

Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;<br />
Password=myPassword;







来自CE设备的可信连接

Windows CE设备通常未经过身份验证并登录到域,但可以使用此连接字符串从CE设备使用SSPI或可信连接和身份验证。






Trusted Connection from a CE device
A Windows CE device is most often not authenticated and logged in to a domain but it is possible to use SSPI or trusted connection and authentication from a CE device using this connection string.

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;<br />
User ID=myDomain\myUsername;Password=myPassword;





请注意,这只适用于CE设备。





通过IP地址连接





Note that this will only work on a CE device.


Connect via an IP address

Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=myDataBase;<br />
User ID=myUsername;Password=myPassword;





DBMSSOCN = TCP / IP是如何使用TCP / IP而不是命名管道。在数据源的末尾是要使用的端口。 1433是SQL Server的默认端口。点击此处了解更多信息。





启用MARS





DBMSSOCN=TCP/IP is how to use TCP/IP instead of Named Pipes. At the end of the Data Source is the port to use. 1433 is the default port for SQL Server. Read more here.


Enable MARS

Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;<br />
MultipleActiveResultSets=true;

Refer - SQL Server 2008的连接字符串 [ ^ ]。



谢谢......

Refer - Connection strings for SQL Server 2008[^].

Thanks...


这篇关于网站无法与sql server通信。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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