Creating a Machine DSN

A machine data source name (DSN) stores information about a data connection in the Windows® Registry of the computer on which the DSN was created.

Note   The information stored in the registry is the same information that is stored in a file DSN. However, you cannot use a machine DSN to create a DSN-less connection as you can a file DSN. For more information about the DSN-less connection, see Creating a File DSN.

In a file DSN, connection information is stored in the Global.asa file. In a machine DSN, the Global.asa file contains a pointer to the information stored in the Windows Registry. Therefore, every computer that uses the project (including the Web server) must have the connection information in exactly the same Registry address. This makes a machine DSN less portable than a file DSN.

However, if you use a machine DSN during development, it is easy to change the database you are working with simply by changing the entry in the Windows Registry; you do not have to change the Global.asa file each time. In addition, machine DSNs are useful if you need to use the same DSN in many different applications on your computer.

To create a new machine DSN

  1. In the Project Explorer, right-click the database project you want to add a data connection to, and then select Add Data Connection.

    Note   In Microsoft® Visual C++®, right-click the database project in FileView.

  2. Select the Machine Data Source tab.

  3. Choose New, and then choose whether you want to create a User Data Source or a System Data Source. A user data source is available only to the user who created it. A system data source is available to any user who logs onto the computer. When you have chosen the data source type, choose Next.

  4. Select the driver for which you want to set up a data source, and then choose Next.

  5. Review the information you have entered. If everything is as you want it, choose Finish. If you want to make changes, choose Back.

  6. Follow the instructions for the Create a New Data Source wizard or the dialog box that is displayed. For help with these dialog boxes, choose the Help button.

    For SQL Server data sources, you use the Create a New Data Source wizard. For other data sources, you use various dialog boxes. For example, for Microsoft® Access data sources, you use the ODBC Microsoft Access 97 Setup dialog box, and for Microsoft® FoxPro® data sources, you use the ODBC Visual FoxPro Setup dialog box.

    Note   When you specify a database, enter a location that will work not only in the development environment you are using, but also in your final project. For example, if your project involves a database that is accessed from a Web server, use a Universal Naming Code (UNC) to be sure that the database location you specify is accessible from the Web server.

If you've created a machine DSN for a server-based database, you will be prompted with the login dialog box for the database server. You will be prompted again each time you connect to the database using the DSN.