Sorry, the message got cut off. To continue:
FUNC newid()
LOCAL nOldSel,cAlias,nNewKey,cOldReprocess
nOldSel=SELECT()
cAlias=ALIAS()
cOldReprocess=SET("REPROCESS")
SET REPROCESS TO AUTOMATIC
IF !USED(mydatabase!identity)
USE mydatabase!identity IN 0
ENDIF
SELECT identity
IF SEEK(UPPER(cAlias), "identity", "TABLENAME")
IF RLOCK()
nNewKey=identity.keyvalue
REPLACE identity.keyvalue WITH identity.keyvalue+1
UNLOCK
ELSE
nNewKey=-1
ENDIF
ELSE
nNewKey=-1
ENDIF
SELECT (lnOldArea)
SET REPROCESS TO lcOldReprocess
RETURN nNewKey
ENDFUNC
The error trapping isn't very sharp in this example, but you'll get the idea.
Of course, an index on TABLENAME is required for table IDENTITY.
Eric Shaneson
Cutting Edge Consulting
>>We are using ado to connect databases over the internet
>>
>>We have a problem with defining new key's using ado
>>
>>Normally we have an extra databases with the latest en highest
>>keys per table.
>>
>>If we create a new key we lock the record and create a new keynumber
>>
>>What is the best way to do this with ado example please.
>>
>>Kind regards
>>
>>
>>Jan Dorresteijn
Eric Shaneson
Cutting Edge Consulting