ONE Active Server Pages Product Home Page Developer Site Version


Creating Connection Strings

When you want to connect to a database from an ASP page, the first step is to create the connection string. This provides information (in the form of parameters and their values) that is 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. Sun ONE Active Server Pages supports the following three approaches to specifying parameters in a connection string:

Note icon Note Connection strings must be constructed according to the requirements of the ODBC driver being used. Sun ONE ASP for Windows uses standard Windows ODBC drivers, so connection strings you developed for Windows will work. However, the ODBC drivers for UNIX and Linux platforms are different than for Windows, so before you can use Windows connection strings with Sun ONE Active Server Pages for UNIX or Linux, you may need to use the syntax described in this section.
   When creating file system references in ASP applications, keep in mind that UNIX and Linux are case-sensitive operating systems. Be sure to use the correct capitalization in all references to files and directories.

Ask your server administrator which approach you should use in your specific 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 in Opening the Database Connection.

Note icon Note On UNIX and Linux systems, Sun ONE ASP installs the ODBC drivers to support a number of databases. However, it does not support all databases on all platforms. To see the list of installed drivers for your platform, see Supported in This Release.

In this section:

Using System DSNs

Using DSN-less Connection Strings

Using File DSNs