Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

ADBOBJECTS()

This function is really a whole bunch of different functions in one. It creates an array containing information about a database, but there are four different types of information that can be put in the array: tables, views, connections or relations. Unlike other functions returning status information, ADBOBJECTS() only works on the current database; you can’t tell it which database to look at.

Usage

nObjectCount = ADBOBJECTS( ArrayName, cInfoType )

Parameter

Value

Meaning

ArrayName

Name

The array into which database information is dumped.

cInfoType

"TABLE"

Put a list of tables in the database into the array.

"VIEW"

Put a list of views in the database into the array.

"CONNECTION"

Put a list of named connections in the database into the array.

"RELATION"

Put a list of persistent relations in the database into the array.

nObjectCount

Positive number

The number of rows in the array (= the number of items of the specified type).

0

No items of the specified type were found.

Unlike most other FoxPro keywords, cInfoType cannot be abbreviated. You must spell out “table”, “view”, “connection” or “relation.” It’s not case-sensitive, however; any combination of uppercase and lowercase will do.

When cInfoType is “TABLE”, “VIEW” or “CONNECTION”, the resulting array is one-dimensional and contains a list of the items of the specified type in the database. For “RELATION”, a five-column array is created:

Column

Meaning

1

Child table.

2

Parent table.

3

The tag the relation is based on in the child table.

4

The tag the relation is based on in the parent table.

5

The referential integrity constraints on the relation in the order Update, Delete, Insert. For each type of integrity, there are three possible values:
C = cascade
R = restrict
I = ignore
If no referential integrity of a type was defined, that position is empty.

The possible values in the fifth column (referential integrity) depend on the trigger. The Insert trigger supports only Restrict and Ignore (and applies to the child table), while the other two accept all three choices.

Using ADBOBJECTS() together with ADATABASES() and AFIELDS(), you can create a pretty good picture of what your environment looks like at any time. Details about the tables, view and connections found with ADBOBJECTS() are available using DBGetProp().

Example

OPEN DATABASE TasTrade
* create arrays of tables, views, connections, and relations
nTableCount = ADBObjects(aTables,"Table")
nViewCount = ADBObjects(aViews,"View")
nConnCount = ADBObjects(aConns,"Connection")
nRelCount = ADBObjects(aRels,"Relation")
* now look at all the info
DISPLAY MEMORY LIKE a*

See Also

ADatabases(), Array Manipulation, DBGetProp(), Key(), Open Database, Relation(), Set Database, Tag(), Target()