display | more...
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.

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