简体   繁体   English

为什么我们不需要DSN才能通过ODBC连接到SQL Server(C#)

[英]Why don't we need a DSN to connect via ODBC to SQL Server (C#)

I have tried a method of connecting to the SQL Server database via ODBC in my .net application (c#) ( System.Data.Odbc ) This works fine. 我尝试了一种在.net应用程序(c#)( System.Data.Odbc )中通过ODBC连接到SQL Server数据库的方法。 However, I did not require to provide a DSN name with the connection string. 但是,我不需要在连接字符串中提供DSN名称。 my connection string looked like this below 我的连接字符串如下所示

"Driver={SQL Server};Server=SQLServerName;UID=sa;PWD=password;Database=Demo;PORT=1000"

I am trying to understand why. 我试图了解原因。

A DSN(Data Source Name) is just the name of a stored connection which contains Driver, Server, Database, Port and so on. DSN(数据源名称)只是存储的连接名称,其中包含驱动程序,服务器,数据库,端口等。 You can use it by it's name. 您可以使用它的名称。 But of course you can also just connect directly with ODBC and provide a complete connection string with all the necessary information yourself. 但是当然,您也可以直接与ODBC连接,并提供包含所有必要信息的完整连接字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM