A list of products available on this site
Documentation for XtraMania's xtras
Prices and links to the online store
Xtras, PDFs, samples
Have a question? Ask us!
Contacts
Logo. www.xtramaina.com  
Home Search E-mail
ADOxtra Usage/a bit advanced databasing

ADOxtra for Macromedia Director

Connection object

In certain cases you may need to use alternative approach to perform required task. For example, you have to create connection object before opening recordset to open recordset inside a transaction. The other example is retrieving database schema information.

Use ADOxtra function CreateObject() with parameter #Connection to create wrapper for ADODB.Connection object:
cnn=CreateObject(xtra"ADOxtra",#Connection)

Check resulting value to ensure that ADO is available. If function succeeded cnn will be the Lingo object reference, otherwise it will be a string, describing error. Use cnn.Version property to determine ADO version:
if objectP(cnn) then
  put "ADO version:"&&cnn.Version
else
  put "Error:"&&db
end if

Then you have to adjust connection parameters using Connection object's properties. See cnn.ConnectionString, cnn.Provider and other properties of the Connection object. Otherwise you may specify connection information as parameters of cnn.Open method. It is definitely good idea do not specify the same kind of information twice, since different versions of ADO may behave differently, deciding which information to take into account. For example, if you set cnn.Provider property and set alternative provider info in the cnn.ConnectionString property, different versions of ADO may try to use different providers, probably generating an error in one of the cases.

Object's dynamic properties

Connection object contains the collection of dynamic properties cnn.Properties. This collection contains multiple properties specific to the provider. You may access this collection after you specify which provider to use. If you do not specify any, the OLE DB provider for ODBC will be used. Once you set the provider of the connection object you cannot change it for this particular instance. After you specify provider you may look at dynamic properties it supports:
cnn.Provider="Microsoft.Jet.OLEDB.4.0"
repeat with i = 0 to cnn.Properties.Count - 1
  put cnn.Properties[i].Name && "=" && cnn.Properties[i]
end repeat

See more details about property object here. You may adjust some dynamic properties:
cnn.Properties["SomePropertyName"]=SomeNewPropertyValue

The recordset object contains its own provider specific collection of the dynamic properties. They may be accessed the same way.

Using transactions

You may use opened connection to start transaction. Use cnn.BeginTrans to start transaction. Use cnn.CommitTrans method to save changes or cnn.RollbackTrans method to cancel the changes being made inside the current transaction.

Site homeSearchContact author © Eugene Shoustrov. www.xtramania.com