<< Click to Display Table of Contents >> Navigation: Apollo COM > Getting Started > Using Apollo COM with Visual Basic |
DIM oTable as object
‘ Local data access
Set oTable = CreateObject("ApolloCOM9.Table")
oTable.AccessMethod = "amLocal"
oTable.DatabaseName = "c:\Apollo\9.9\x86\Data\"
oTable.TableName = "TEST.DBF"
‘ Client/Server data access
‘ must have Apollo Server running at this IP address
Set oTable = CreateObject("ApolloCOM9.Table")
oTable.AccessMethod = "amServer"
oTable.User = "SYSDBA"
oTable.Password = "masterkey"
oTable.Host = "127.0.0.1"
oTable.DatabaseName = "MyAlias" ‘ alias set in Apollo Server
oTable.TableName = "TEST.DBF" ‘ table name
‘ Creating a new index tag called "MyTag"
‘ IndexTag( cpFileName, cpTagName, cpExpr, iOption,
' bDescend cpCondition)
oTable := CreateObject("ApolloCOM9.Table")
oTable.DatabaseName = "c:\Apollo\9.0\x86\Data\"
oTable.TableName = "TEST.DBF"
oTable.Exclusive = True ‘must open in exclusive mode to index
oTable.Open
oTable.IndexTag("TEST", "MyTag",
"Upper(Trim(LAST))+Upper(Trim(FIRST))', 0, False, "")
oTable.IndexTag("TEST", "SocSec", "SECURITY", 0, False, "")
oTable.IndexTag("TEST", "Address", "Upper(ADDRESS)", 0, False, "")
‘ Finding a value (set the index and seek)
oTable.ActiveIndex = "MyTag"
if oTable.Seek( "SMITH" ) then
MsgBox "found"
if oTable.Seek( 'SMITH JOE') then
MsgBox "found"
if oTable.Seek( 'SM') then
MsgBox "found"
‘ Filtering (scope) using high-speed Mach-Six engine
‘ Must have index set on this value
‘ This will instantly show records with SECURITY >000 and <999
oTable.ActiveIndex = "SocSec"
‘ set the upper and the lower limit
oTable.SetScope( "000-000-000", "000-000-999")
oTable.GoTop
oTable.QueryRecCount ‘ # of records in the scope
oTable.SetScope('','') ‘ clear the scope
oTable.RecCount ‘ total records in table
‘ Misc. settings: do not show deleted records!
oTable.SetDeleted = True
‘ Traversing a table
oTable.GoTop
While not oTable.Eof
oTable.GetString("LASTNAME")
oTable.Skip(1)
Wend
‘ Retrieving data from fields in a table
oTable.GetString('FIRST')
oTable.GetString('LAST')
oTable.GetLogical('MARRIED')
oTable.GetInteger('AGE')