Chapter 3 DynaScript Predefined Objects


connection object

Object

Describes a connection to a database.

Syntax

To use a connection's property:

connection.propertyName

To use a connection's method:

connection.MethodName( parameter ) 

Description

Dynamo requires two types of connections:

When you create a Dynamo Web site, your Dynamo connection becomes the default for your user connection as well. This connection information is encapsulated in the <default> connection object.

You can use Sybase Central to change the default connection associated with a script. For a detailed explanation of connections, see "Working with connections" in the PowerDynamo User's Guide.

If your database content is stored in one or more other data sources, you can then create more connection objects to manage those sources.

There are two ways to create connection objects. To create a permanent User connection that is added to the Connections folder, use this format:

For an ODBC connection:

site.CreateConnection( connName, description, dataSource [,userName, password, ODBC, connectParameters] )

For an Open Client connection:

site.CreateConnection( connName, description, 
server, userName, password, Open Client [,database] )

The preferred method of creating a permanent user connection, however, is to use Sybase Central to create it from within a script. For additional information, see "Creating, deleting, modifying, and testing User connections" in the PowerDynamo User's Guide.

For a temporary connection which lasts only as long as your script is executing, use the following:

To create an ODBC connection:

X = new Connection ( name, description, datasource [,userName, password, ODBC, connectParameters] );

To create an Open Client connection:

X = new Connection ( name, description, 
server, userName, password, Open Client [,database] );

If a connection is not successfully created, null is returned. Use site.GetState, site.GetErrorInfo, and site.GetErrorCode to retrieve information about the state of the connection.

Note  

chained mode
Open Client connections are automatically set to CHAINED = ON which is equal to autoCommit=false. Use autoCommit property to set chained mode to off (autoCommit=true).

Note  

The connection object
If there is no connection associated with a script (the connection shown in the document properties is "no connection"), then there will not be a connection object.

The site object allows you to manipulate your Web site connections. For information on CreateConnection, DeleteConnection or GetConnection see "site object"

Example

This script creates a permanent ODBC connection called myConn. Once created, this connection is visible from the Connections folder in Sybase Central:

<!--SCRIPT
/* creates a permanent ODBC connection */
site.CreateConnection ( "myConn","My new ODBC connection","Godzilla","dba","sql","ODBC" );
-->

See also

"Connect method"

"Disconnect method"

"GetSupportedMoves method"

"Rollback method"

 


Copyright © 1999 Sybase, Inc. All rights reserved.