GetConnection

Description

Gets a reference to a database connection defined in the DatabaseConnections dialog box. This method is not implemented for JSP targets.

Applies to

PSServerClass object

Syntax

psServer.GetConnection( name )

Argument

Description

name

The name of the connection

Returns

PSConnectionClass object

Usage

In a server script that uses the Web Target object model, you can use a database connection that has been predefined in the Database Profiles painter in PowerBuilder. In the Web Target user interface, you can include connections for deployment to your Web server by selecting them on the Database tab of the Web target properties dialog box. To use the same connections for a Web DataWindow, you must make sure that the connections are also defined for the server hosting your Web DataWindow generator component.

In an ASP target at runtime, GetConnection opens a connection defined in the Global.asa file.

Examples

Example 1

The following example gets a reference to the connection called “SalesDBConnection” and stores the object reference in the myconnect variable. If GetConnection is successful, it uses the connection object to create a cursor:

myconnect =
		psServer.GetConnection("SalesDBConnection");
if ( myconnect.GetError() == null )
		{
		myquery = "Select * from sales"; 
		mycursor = myconnect.CreateCursor( myquery );
		if ( myconnect.GetError() == null )
			{
			// Process the retrieved data
			}
		else dberror = true;
		}
else dberror = true;