Specifies connection information for a DataWindow or DataStore.
To specify connection information |
Use |
---|---|
Using values from an external transaction object |
|
For the Web DataWindow server component |
Sets the values in the internal transaction object for a DataWindow control or DataStore to the values from the specified transaction object. The transaction object supplies connection settings, such as the database name.
integer dwcontrol.SetTrans ( transaction transaction )
Argument |
Description |
---|---|
dwcontrol |
A reference to a DataWindow control, DataStore, or child DataWindow in which you want to set the values of the internal transaction object |
transaction |
The name of the transaction object from which you want dwcontrol to get values |
Returns 1 if it succeeds and -1 if an error occurs. If any argument’s value is NULL, the method returns NULL.
In most cases, use the SetTransObject method to specify the transaction object. It is more efficient and allows you to control when changes get committed to the database.
SetTrans copies the values from a specified transaction object to the internal transaction object for the DataWindow control or DataStore. When you use SetTrans in a script, the DataWindow uses its internal transaction object and automatically connects and disconnects as needed; any errors that occur cause an automatic rollback. With SetTrans, you do not specify SQL statements, such as CONNECT, COMMIT, and DISCONNECT. The DataWindow control connects and disconnects after each Retrieve or Update function.
Use SetTrans when you want PocketBuilder to manage the database connections automatically because you have a limited number of available connections or expect to use the application from a remote location. SetTrans is appropriate when you are only retrieving data and do not need to hold database locks on records the user is modifying. For better performance, however, you should use SetTransObject.
DBMS connection settings
You must set the parameters required to connect to your DBMS
in the transaction object before you can use the transaction object
to set the DataWindow’s internal transaction object and connect
to the database.
Updating more than one table When you use SetTrans to specify the transaction object, you cannot update multiple DataWindow objects or multiple tables within one object.
This statement sets the values in the internal transaction object for dw_employee to the values in the default transaction object SQLCA:
dw_employee.SetTrans(SQLCA)
The following statements change the database type and password of dw_employee. The first two statements create the transaction object emp_TransObj. The next statement uses the GetTrans method to store the values of the internal transaction object for dw_employee in emp_TransObj. The next two statements change the database type and password. The SetTrans method assigns the revised values to dw_employee:
// Name the transaction object.
transaction emp_TransObj
// Create the transaction object.
emp_TransObj = CREATE transaction
// Fill the new object with the original values.
dw_employee.GetTrans(emp_TransObj)
// Change the database type.
emp_TransObj.DBMS ="Sybase"
// Change the password.
emp_TransObj.LogPass = "cam2"
// Put the revised values into the
// DataWindow transaction object.
dw_employee.SetTrans(emp_TransObj)
Specifies connection information for the Web DataWindow, such as the database name.
Web DataWindow server component
integer dwcontrol.SetTrans ( string dbms, string dbparm, string lock, string logid, string logpass, string database, string servername )
Returns 1 if it succeeds and -1 if an error occurs.
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |