image\cslogo3d1.gif

Opening the Database Connection

Chili!Soft ASP 3.6 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 Chili!Soft ASP 3.6 to open a database connection, as described in this topic.

Note

Chili!Soft ASP 3.6 installs the ODBC drivers for 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 the "Installing and Uninstalling Chili!Soft ASP" section of "Chapter 2: Installing and Configuring Chili!Soft ASP." It is also a good idea to ask your system administrator to verify that the ODBC driver for your database is functioning correctly.

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:

dbConn.open 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 you want, you can also use FrontPage 2000 for creating connection strings and displaying data on a Web page, as described in "Using FrontPage Database Features" in this chapter.

Note

Chili!Soft ASP 3.6 includes the ODBC drivers required to connect to a number of different databases. 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 non-production server because a malfunctioning ODBC driver can bring down your ASP Server.

See also:

Connecting to a Database in this chapter.

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