Function DbSession() Foundation

Retrieves the DacSession object of the current work area.

Syntax
DbSession([nWorkArea|cAlias]) --> oDacSession | NIL
Parameters
<nWorkArea>
<nWorkArea> is a positive integer specifying the ordinal number of the work area from which the session object is retrieved. If not explicitly specified, the current work area is used.
<cAlias>
Alternatively, <cAlias> can be specified for <nWorkArea>. If used, <cAlias> is a character string containing the alias name for the work area from which the session object is retrieved. If not specified, the current work area is used.
Return

The function returns the DacSession object managing the connection to the data source of the work area. If the table open in the work area is accessed without a DacSession object or if the work area is not used, the return value is NIL.

Description

When an Xbase++ program accesses a database server, it must establish a connection to the server before tables of the database can be used. The connection is established by a DacSession object. Multiple servers can be accessed using multiple connections, so that multiple tables from different servers may be used in the application. If this is the case, the DbSession() function is helpful when the DacSession object maintaining the connection to the data source of the current work area must be retrieved.

Examples
// The example outlines a typical usage scenario for DbSession(). 
// It retrieves the message that is associated with the last 
// operation of a database server. 

<connection to data source> 

<USE databases> 

SELECT Customer 

? DbSession():getLastMessage() 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.