Product Home Page | Developer Site | Version | |
Sun ONE Active Server Pages includes an 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.
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 ONE ASP to open a database connection.
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. |
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.
If desired, you can also use FrontPage to create connection strings and display data on a Web page, as described in Using FrontPage Database Features.
Note | 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. Also, be sure to test the driver on a nonproduction server. A malfunctioning ODBC driver can bring down your ASP Server. |
See also:
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.