Sun Chili!Soft ASP Sun Chili!Soft
ASP Sun Microsystems


Opening the Database Connection

Sun Chili!Soft ASP includes an ActiveX Data Object (ADO) control that developers can use for initializing connections to databases and for retrieving and manipulating data on a Web page. The ADO Connection object opens and closes database connections by using ODBC drivers. Other ADO objects act as containers for storing information that is passed to and from the database. The most common container is a Recordset object, which stores the results of a SELECT SQL query.

The topic, "Creating Connection Strings," explains the first step to take to connect an ASP page to a database. After creating the connection string, your next step is to use the ADO control included with Sun Chili!Soft ASP to open a database connection, as described in this topic.


On UNIX and Linux systems, Sun Chili!Soft 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, go to the platform-specific installation requirements section in "Installing and Uninstalling Sun Chili!Soft ASP" in "Chapter 2: Installing and Configuring Sun Chili!Soft ASP."

To open a database connection, you first add code for creating an instance of the ADO Connection object, as shown in the following example:

set dbConn = server.createObject("ADODB.connection")

Next, you add code to call the Connection object Open method, which takes the connect_string parameter, as shown in the next example: connect_string

This sends a request to the ODBC Manager to create an instance of the ODBC driver specified by the connection string that you previously created. ADO then passes the remainder of the connection string to the ODBC driver, which uses this information for connecting to the database.

Once you have established the connection, you can use the other ADO objects to retrieve, display, and manipulate data on your Web page, as described in "ADO Component Reference" in "Chapter 5: Developer's Reference."

If desired, you can also use FrontPage for creating connection strings and displaying data on a Web page, as described in "Using FrontPage Database Features" in this chapter.


Before you create a database connection, it is recommended that you ask your system administrator to verify that the appropriate ODBC driver for your database is configured and functioning properly. It is a good idea to test the driver on a nonproduction server because a malfunctioning ODBC driver can bring down your ASP Server.

See also:

Connecting to a Database in this chapter.

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