Creating an AdoTransaction object

An AdoTransaction object has four properties: Connection, DbParameter, IsBound, and Transaction. They are described in Table 5-3.

Table 5-3: AdoTransaction object properties

Property

Datatype

Description

Connection

System.Data.IDbConnection

The ADO.NET connection that the AdoTransaction object binds to the database interface layer. DataWindows that use the AdoTransaction object use this connection to perform database operations such as retrieve and update.

DbParameter

String

Database parameters to be passed to the database interface layer for processing. For a description of each parameter that the database interface supports, see the chapter on setting additional connection parameters in Connecting to Your Database.

IsBound

Boolean

Read-only property that indicates whether the ADO.NET connection associated with this AdoTransaction object has been bound to the database interface layer.

Transaction

System.Data.IDbTransaction

The ADO.NET transaction that is started within the AdoTransaction's Connection property.

When you create a new AdoTransaction object, you can pass the name of the Connection object as a parameter of the constructor or call the constructor with no parameters and specify the Connection object using the Connection property.

You can also optionally supply database parameters to be passed on to the database interface layer. An easy way to determine the correct syntax for setting these parameters is to set them in the DataBase Profile dialog box for ADO.NET and copy them from the Preview page. See “Using the Preview tab to connect in DataWindow Designer”.

In the following example, an OleDbConnection object is passed in the constructor (no database parameters are passed), then the connection is bound to the database interface layer:

[Visual Basic]
Imports Sybase.DataWindow
...
Friend WithEvents adoTrans As AdoTransaction
...
Me.adoTrans = New AdoTransaction(oleDbConn)
adoTrans.BindConnection()

[C#]
using Sybase.DataWindow;
...
private AdoTransaction adoTrans;
...
this.adoTrans = new AdoTransaction(oleDbConn);
adoTrans.BindConnection();

The BindConnection method binds the connection object passed in the constructor to the database interface layer and sets the IsBound property to true. If you need to change the Connection object associated with the AdoTransaction, or change or add any database parameters, you must call the UnbindConnection method first.