ACE/400 Data Control can be used with many applications such as:
What are the benefits of Data Control?
The main advantage of Data Control is to fit a standard way of database
programming. This standard has been established by Microsoft with the
Microsoft DAO. The DAO is based on the latest portability norm that is OLE. In fact, Data Control is an OLE control. A data control (if OLE and DAO compliant) has two integrated parts:
- a visual part, that can be used in VB to link in STANDARD components
that take a ‘data source’, called ‘Data Control’,
- and a type library that provides objects to access the Data. This part
is called ‘DAO OLE Type library.’
With ACE/400 Data control, these two parts are combined on a single
OCX file named EACDAO.OCX. The Ace/400 Data Control system has been
designed to be:
- easy to use
- intuitive
- portable to every application in windows that is OLE compliant.
The major benefit of using Data Control is its similar interface with
VB, Excel, Access, Powerbuilder and others.
ACE/400 Data Control Features
ACE/400 Data Control key features are:
- easy to use,
- compatible with the standard controls (Text, Static, Listbox, grid and so on) of Visual Basic,
- can be used with ACE/400 for VB,
- provides access to AS/400 Files (with members) and SQL Queries,
- provides navigation methods (first, next, previous, last, skip),
- provides key searches,
- its ease of conversion from other applications using Microsoft Data Control (ODBC for example).
ACE/400 Data Control has very similar methods and properties as the
regular VB Data control (the object named ‘Data’).
ACE/400 Data Control OLE Type Library Details
As explained above, ACE/400 Data Controls have an OLE Type Library
section. This Type Library is very similar to the Microsoft DAO Type
library. It is composed of different objects:
- ‘ACE400’ which contains global methods or properties,
- ‘Database’ which represents a connection to the AS/400,
- ‘Databases’ which is a set of Databases,
- ‘Recordset’ which represents an opened file or query,
- ‘Field’ which represents a field for a Recordset,
- ‘Fields’ which is a set of ‘Field’ objects
The Data control is represented by the name ACE400Data. All of these
objects and methods can be easily browsed using the object browser in VB.
A small help text is available with each property or method.
1. "ACE400" object
This object contains default properties or methods for the OLE type
library. Available methods and properties:
Opendatabase: opens a Database
This method takes the parameters (all optional):
- Name (string): this is an alias name and if used twice in one method, the same connection will be used.
- Options: not used yet, for compatibility only
- ReadOnly: not used yet, for compatibility only
- Connect (string): optional parameters. This string has the form:
USER=WWW;PASSWORD=WWW;ALIAS=XXXX;MACHINE=YYYY
Connect string available options are:
- USER: username
- PASSWORD: password
- ALIAS: replaces the first parameter
- MACHINE: AS/400 name to connect
If multiple ‘opendatabase’s are made on different machines, this will
automatically generate multiple sessions.
2. "Databases": property representing all connections.
3. "Database" object
This object represents a connection to the AS/400. So, all operations
that belong to a connection are available through this object:
- Close: closes a connection
- Openrecordset: opens a file or a query
- BeginTrans: begins a transaction
- CommitTrans: commits changes in transaction mode
- Rollback: cancels changes in transaction mode
Please note that only files opened with Commit mode will be affected
with transaction methods. Of course these files must also be journalized.
4. "Recordset" object
This is the richest object because it contains all operations available
on the file. It can be obtained in two ways:
- by the property ‘Recordset’ of the data control
- by a database.Openrecordset
Useful properties:
- BOF: Boolean true if before the beginning of file
- EOF: Boolean true if after the end of file
- Fields: allows access to field values
- NoMatch: true if last seek failed
- Bookmark: useful to store/restore position in the file
Useful methods:
- MoveFirst, MoveLast, MoveNext, MovePrevious: standard navigation
methods
- Edit: puts the current record in edit mode (and locks the current
record)
- AddNew: adds a new record
- Updates: commits changes made on the line (insert or update)
- Delete: deletes the current record (after having made Edit).
- CancelUpdate: returns to normal mode
- Seek: make a key search
- Resync: used to synchronize the Data after having used Easycom for VB
on the same handle.
5. "Fields" object
This object allows you to get the set of
fields available for a recordset. It can be used in two ways:
- Walking in a set:
In VB, this can be done like this:
For each Field in recset.Fields
Debug.print Field
Next Field
- Walking using Item property:
For i = 0 to recset.Fields.count
The following data access programming ways are equivalent:
Debug.Print recset(i)
Debug.Print recset.Fields(i)
Debug.Print recset.Fields(i).Value
Next i
6. "Field" object
This object allows you to get or set values for a field. Getting and
setting value is done by a simple affectation. In fact, the property value is the default property for the object. Other properties include:
- Name: Native name for the field
- FieldSize: Native size of the field (in bytes)
- Text: Text associated to the AS/400 field
- ColHdg1,ColHdg2, colHdg3: column heading of the field