A DSN, or Data Source Name (not to be confused with DNS, the Domain Naming System), is a major component of getting a database to work statically, through the common APIs in Windows. Where this comes in handy is underneath Windows Scripting Technology applications, such as server-side IIS scripts. These scripts inside of IIS, and other database-aware application can heavily simplify getting data from a Windows specific source by using this convention.

Did you know, that by default, Windows comes with a method to read and write data to Excel, Oracle, and Access databases? (No Microsoft Office needed). All you need to do is set a system-wide DSN for the database you want to use, and give it the ODBC driver through which to interpret the database. By using an API layer on top of the ODBC APIs (such as ADO, CDO, or any other third party OLE DB component), you get greater power and flexibility out of these named databases. Using a DSN greatly simplifies the process of setting up and initiating an ODBC connection. Software engineers do not want to fiddle around with debugging their own drivers and such. Use preworking components whenever possible.

There is a huge argument over whether or not to use them for ultimate performance in IIS, where it really can make a difference, given the number of database lookups any particularly dynamic site may have. All in all, I think there is greater performance to call the database string by hand, but it is much more of a pain in the ass. If you have the cycles to spare, don't be so spartan with them, IMO, and leave you code readable.

In ASP code, it would look something like this:
<%
    set myConn = Server.CreateObject("ADODB.Connection")

    myConn.Open "myDSN"
%>

rather than

<%
    set myConn = Server.CreateObject("ADODB.Connection")

    myConn.Open "driver=(SQL Server);;uid=sa;pwd=;database=myDSN"
%>
...

And that's a very simplified connection string to SQL server.


You can find out more about DSNs, how they work, and how to set them up under the ODBC control panel in any of the Windows releases above Windows 95.

DSN is the Defense Service Network, a telephone system used by the US Department of Defense, that links military posts throughout the world. The numbers are designed on the American model, with seven major digits. In addition, each continent on which there is a significant US military presence has a different "area code": 312 for North America, 314 for Europe, and 318 for Asia. DSN numbers can only be dialed from DSN phones, and only if the number you're dialing has a different "area code" than you do is it required to dial it. In this way, a commander at, say, the Pentagon, can call a subordinate in Korea, without having to deal with long distance charges at government expense.

DSN usually works very well, but it can be a little spotty on occasion due to links in some remoter areas being through satellite.

Log in or registerto write something here or to contact authors.