image\cslogo3d1.gif

Creating Connection Strings

When you want to connect to a database from an ASP page, your first step to is to create the connection string. This provides information—in the form of parameters and their values—required for the server to establish the connection.

Each type of database has a specific set of parameters for which you must specify values; these are the required parameters. Some databases also provide optional parameters that you can specify to implement special features.

Exactly what you must include in a connection string depends on the type of database and the approach you use to specify its parameters. Chili!Soft ASP 3.6 supports the following three approaches to specifying parameters in a connection string:

·              System DSNs. With a system DSN, all you need to provide in the connection string is the name of the DSN that your system administrator has configured for the database on the ASP Server. For more information, see "Using System DSNs" in this section.

·              File DSNs. A file DSN is similar to a system DSN, except the database information is contained in a file (*.dsn) that can be stored in the root directory for a virtual host, rather than being stored centrally by the ASP Server. File DSNs are useful in shared Web hosting environments because a system administrator does not need to configure each file DSN; users can configure their own. For more information, see "Using File DSNs" in this section.

·              DSN-less connection strings. With a DSN-less connection string, you specify all of the required database information in the connection string. For more information, see "Using DSN-less Connection Strings" in this section.

Note about using Windows connection strings with Chili!Soft ASP for Linux or UNIX

Connection strings must be constructed according to the requirements of the ODBC driver being used. Chili!Soft ASP for Windows NT uses standard Windows ODBC drivers, so connection strings you developed for Windows will work. However, the ODBC drivers for Linux and UNIX platforms are different than for Windows, so before you can use Windows connection strings with Chili!Soft ASP for Linux or UNIX, you must edit them to use the syntax described in this section.

When creating file system references in ASP applications, bear in mind that Linux and UNIX are case-sensitive operating systems. Be sure to use the correct capitalization in all references to files and directories.

Ask your server administrator which one of these approaches to use in your particular Web server environment.

Once you have created the connection string in your ASP page, you can add the code needed to open a database connection, as described next, in "Opening the Database Connection."

Note

Chili!Soft ASP 3.6 installs the ODBC drivers to support a number of databases, but it does not support all databases on all platforms. You can view the list of installed drivers in the Installation Requirements topic for your platform in "Installing and Uninstalling Chili!Soft ASP" in "Chapter 2: Installing and Configuring Chili!Soft ASP."

Copyright 2001 Sun Microsystems, Inc. All rights reserved. Legal Notice.