Definition of Data Source Nama in the Network Encyclopedia.
What is Data Source name (DSN)?
DSN stands for Data Source Name, is a unique name used to create a data connection to a database using open database connectivity (ODBC). The data source name (DSN) is used by applications that need to access or manage data in the database.
All ODBC connections require that a DSN be configured to support the connection. When a client application wants to access an ODBC-compliant database, it references the database using the DSN.
You can configure a DSN for an ODBC-compliant database using the Microsoft Windows NT ODBC or the Windows 2000 Administrative Tools\Data Sources (ODBC) utility in Control Panel. You can create three kinds of DSNs:
- A user DSN, which is visible only to the user who creates it and can be used only on the current machine.
- A system DSN, which is visible to all users on the machine and is also accessible to Windows NT and Windows 2000 services. A system DSN is stored in the registry.
- A file DSN, which can be shared by users who have the same ODBC drivers installed. A file DSN is stored in a file.
Examples of Data Source Name usage
ASP (VBScript) code to open a DSN connection might look like the following:
Dim DatabaseObject1 Set DatabaseObject1 = Server.CreateObject("ADODB.Connection") DatabaseObject1.Open("DSN=example;")
In PHP using the PEAR::DB package to open a connection without an external DSN (a “DSN-less connection”, i.e., using a Connection String), the code might resemble the following
require_once("DB.php"); //$dsn = "<driver>://<username>:<password>@<host>:<port>/<database>"; $dsn = "mysql://john:pass@localhost:3306/my_db"; $db = DB::connect($dsn);
When you design Web applications that use Microsoft ActiveX Data Objects (ADO) for accessing database information, be sure to use either a file DSN or a system DSN because ADO does not work with user DSNs.