且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Asp.Net和MSSQL数据库连接

更新时间:2023-10-05 12:16:52

让我先了解你的具体要求是什么?



ASP.NET应用程序在Web服务器。

SQL Server在同一台服务器上。



您可以使用服务器中安装的sql server实例进行连接。



标准安全

Let me first understand what is your exact requirement?

ASP.NET app is in web server.
SQL Server is in the same server.

You can connect using sql server instance installed in the server.

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





可信连接

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



使用Sql Server实例



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

using Sql Server Instance

Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;







现在,如果你的sql服务器存在于不同的服务器中

使用IP地址连接



数据源= 190.190.200.100,1433;网络库= DBMSSOCN;

初始目录= myDataBase;用户ID = myUsername;密码= myPassword;





现在,如果你的机器中存在sql server -

连接的场景是荒谬的



希望这会有所帮助!

干杯




Now, if your sql server exists in a different server
Connect using IP address

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


Now, if your sql server exists in your machine -
the scenario to connect is absurd

Hope this helps!
Cheers