Both the Web ActiveX and the Transaction Object control can establish a database connection. The one you use depends on your needs.
There are two main reasons to use the Transaction Object control:
You can make one database connection for several Web ActiveX controls, saving the overhead of multiple connections.
You can control transaction processing with Connect and Disconnect methods, equivalent to the SQL statements CONNECT and DISCONNECT. If the AutoCommit property is set to false, you can control when an update is committed or rolled back with Commit and Rollback methods.
If you have only one control and are simply retrieving data, you do not need either of these features. Instead of instantiating a separate control, you can set the connection properties of the Web ActiveX itself and allow it to connect and disconnect for each database access.
To use a transaction object with the Web ActiveX, you add an OBJECT element to the Web page. You can provide the connection information in HTML PARAM elements or in JavaScript statements.
The HTML to instantiate a transaction object looks like this:
<OBJECT id=trans1 height=27 name=trans1 classid="..." width=36>
<PARAM VALUE=dba NAME=LogID></PARAM>
<PARAM VALUE=sql NAME=LogPass></PARAM>
<PARAM VALUE=
"Driver='com.sybase.jdbc3.jdbc.SybDriver',
URL='jdbc:sybase:Tds:localhost:7373'"
NAME=dbParm></PARAM>
<PARAM VALUE="" NAME=Lock></PARAM>
<PARAM VALUE=0 NAME=AutoCommit></PARAM>
</OBJECT>
To connect to the DBMS and associate the transaction object with a Web ActiveX, you would write JavaScript like this:
trans1.Connect();
if (trans1.GetSQLCode() == 0) {
dw1.SetTransObject(trans1);
}
For more information about using the Web ActiveX and Transaction Object control, see the DataWindow Programmers Guide.