Overview of Database Connectivity in PowerSite 7
A Web-based application built with PowerSite may use either ODBC or native database connections. In addition, the application may use either a native application server object model for accessing data, or the PowerSite common object model.
It is important to understand, however, that the type of database connections and object model you choose to use may impact the flexibility and options for application deployment.
Application Server Connectivity
Both of the application servers that PowerSite supports -- Sybase PowerDynamo and Microsoft ASP -- offer connectivity through ODBC. In addition to ODBC, PowerDynamo supports Open Client as well.
Due to these differences in support, your choice of database connectivity impacts both your deployment options, and the object models you may reference in the server-side scripts.
If your application uses ODBC database connections:
- Server-side scripts may reference either the PowerSite or native application server object model
If your application uses native database connections:
- Server-side scripts may only reference the native application server object model 1
- Deployment is restricted to the specific application server that supports the native connection 2
Application Server Object Models
Both PowerDynamo and ASP provide an object model that allows you to connect to a database and access data. However, the names and features of the objects and methods differ in each application server.
For example, to connect to a database:
- PowerDynamo provides the Connect() method on the connection object
- ASP provides the Open() method on the Connection object
Use of these native objects and methods in your scripts restricts your deployment to the specific application server that supports those objects. 2
The PowerSite Object Model
An alternative to using native objects and methods provided by specific application servers, the PowerSite object model allows you to write server-side scripts that may be deployed to either PowerDynamo or ASP.
This object model provides an open, conceptual set of objects and methods for database connectivity and data access. It includes support for the common set of features that are available in the native object models. Server-side scripts that use the PowerSite object model can be deployed to either PowerDynamo or ASP. At deployment time, a file is generated that "maps" the conceptual objects and methods to the native objects and methods in the application server to which you are deploying.
This means that you can write your scripts once, then deploy them to several different application server types without making any changes. For example, the GetConnection() method of the psServer object allows you to connect to any ODBC data source. When the script is deployed and executed in an application server, the appropriate native object and method would be used instead, via the "map" file that PowerSite included in the deployment.
The database features available with the PowerSite object model include the ability to:
- connect to one or more databases via ODBC
- execute SQL statements
- navigate through the result set in a cursor
- handle database errors
If you plan to deploy your application to more than one brand of application server, or if you believe there is a chance that your choice of application server software may change in the future, you should use the PowerSite object model rather than a native one.
The Sybase HTML DataWindow Design Time Control (DTC)
PowerSite includes the HTML DataWindow DTC to facilitate the process of writing server-side scripts to access the Web DataWindow component. The HTML DataWindow DTC allows you to quickly build database-enabled web pages with update and navigation capabilities.
Designed for openness, the HTML DataWindow DTC uses ODBC database connections and generates server-side script utilizing the PowerSite object model. As a result, the script generated by the HTML DataWindow DTC can be deployed to any of the supported application servers.
You can also write your own script to access the Web DataWindow using native database connections. For more information about using native connections, seeScripting Against The Web DataWindow
1There is one exception. You can use the PowerSite object model and reference an ODBC connection, then deploy to PowerDynamo and change the connection object definition in PowerDynamo to use Open Client instead of ODBC.
2If you wish to support multiple application servers, yet still use native connections and/or object models, you can detect the application server type at runtime and branch the script to execute the appropriate logic for the specific server. PowerSite provides support for this type of implementation with the psServer object Type() method.