Public pvDBConnstring, nConn pvdbconnstring = "Driver=SQL Server;Server=SQL;uid=sa;pwd=sapassword;Database=bbox" nConn = SQLStringConnect(pvdbconnstring) If nConn <= 0 MessageBox("connection failed") Return Endif Set Procedure To sampleca Additive oSampleMstr = CreateObject("caSampleMstr") oSampleMstr.Alias = 'samplemstr' oSampleMstr.CursorFill(.T.,.F.) Select samplemstr Insert Into samplemstr (refdate, fullname) Values (Date(), 'CZARINA') Wait Window Str(oSampleMstr.ctrlno) && returns zero always TableUpdate(1,.T.,'samplemstr') Close All Procedure sampleca Define Class caSampleMstr As CursorAdapter DataSourceType = 'ODBC' && 'XML', 'NATIVE', 'ADO' AllowUpdate = .T. AllowDelete = .T. AllowInsert = .T. SendUpdates = .T. CursorSchema = [ctrlno Int(4), refdate D(8), fullname C(50)] Selectcmd = [Select ctrlno, refdate, fullname From samplemstr] UpdatableFieldList = [refdate, fullname] UpdateNameList = [refdate samplemstr.refdate, fullname samplemstr.fullname] Tables = 'samplemstr' BuffermodeOverride = 5 KeyFieldList = 'ctrlno' Wheretype = 3 Procedure Init *-- The data source is our Connection Handle This.DataSource = nConn This.AddProperty('ctrlno',0) EndProc Procedure AfterInsert LPARAMETERS cFldState, lForce, cInsertCmd, lResult This.ctrlno = samplemstr.ctrlno EndProc