简体   繁体   中英

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. However, I did not require to provide a DSN name with the connection string. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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