Using a transaction object with the Web ActiveX
When to use a separate transaction object
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.
Instantiating a transaction object
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:
|
1 |
<OBJECT id=trans1 height=27 name=trans1 classid="..." width=36> |
|
1 |
<PARAM VALUE=dba NAME=LogID></PARAM> |
|
1 |
<PARAM VALUE=sql NAME=LogPass></PARAM> |
|
1 |
<PARAM VALUE= |
|
1 |
"Driver='com.sybase.jdbc3.jdbc.SybDriver', |
|
1 |
URL='jdbc:sybase:Tds:localhost:7373'" |
|
1 |
NAME=dbParm></PARAM> |
|
1 |
<PARAM VALUE="" NAME=Lock></PARAM> |
|
1 |
<PARAM VALUE=0 NAME=AutoCommit></PARAM> |
|
1 |
</OBJECT> |
To connect to the DBMS and associate the transaction object
with a Web ActiveX, you would write JavaScript like this:
|
1 |
trans1.Connect(); |
|
1 |
if (trans1.GetSQLCode() == 0) { |
|
1 |
dw1.SetTransObject(trans1); |
|
1 |
} |
For more information about using the Web ActiveX and Transaction
Object control, see the DataWindow Programmers Guide.