Database Source Name
From Wikipedia, the free encyclopedia
A data source name (DSN) is a data structure that contains the information about a specific database that an Open Database Connectivity ( ODBC ) driver needs in order to connect to it. Included in the DSN, which resides either in the registry or as a separate text file, is information such as the name, directory and driver of the database, and, depending on the type of DSN, the ID and password of the user. The developer creates a separate DSN for each database. To connect to a particular database, the developer specifies its DSN within a program. In contrast, DSN-less connections require that all the necessary information be specified within the program.
There are three kinds of DSN:
User DSN (sometimes called machine DSN)
System DSN
File DSN
User and system DSNs are specific to a particular computer, and store DSN information in the registry. A user DSN allows database access for a single user on a single computer, and a system DSN for any user of a particular computer. A file DSN contains the relevant information within a text file with a .DSN file extension, and can be shared by users of different computers who have the same drivers installed.
[edit] Example of use
Using a DSN to connect to a MySQL database through the Web, Web users can submit form entries to a MySQL database by establishing a connection to the MySQL database's DSN.
The advantage of a DSN is that applications can take advantage of any database, as long as DSN is supported (i.e. in Apache/PHP, IIS/ASP)
In ASP (VBScript), to open a DSN connection, the code is:
Dim DatabaseObject1 Set DatabaseObject1 = Server.CreateObject("ADODB.Connection") DatabaseObject1.Open("DSN=DSNname;")
In PHP : ???