Subject Re: [IBO] Record was not located to delete
Author Helen Borrie
At 05:36 PM 20/10/2004 +0000, you wrote:


>Thanks, Helen. I am attaching my query below,
>
>*****************************************
> object SessionQry: TIBOQuery
> Params = <>
> AutoCalcFields = False
> AutoFetchAll = True
> ColumnAttributes.Strings = (
> 'CLIENT_ID=REQUIRED')
> CommitAction = caRefresh
> DatabaseName = 'NDSERVER'
> GeneratorLinks.Strings = (
> 'SESSION_MGR.CLIENT_ID=SESSION_MGR_GEN')
> IB_Connection = SessionConnect
> KeyLinks.Strings = (
> 'CLIENT_ID')
> RecordCountAccurate = True
> AfterInsert = SessionQryAfterInsert
> AfterPost = SessionQryAfterPost
> RequestLive = True
> SQL.Strings = (
> 'select * from SESSION_MGR')
> FieldOptions = []
> Left = 112
> Top = 304
> object SessionQryCLIENT_ID: TIntegerField
> FieldName = 'CLIENT_ID'
> Origin = 'SESSION_MGR.CLIENT_ID'
> ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
> Required = True
> end
> object SessionQryCLIENT_NAME: TStringField
> FieldName = 'CLIENT_NAME'
> Origin = 'SESSION_MGR.CLIENT_NAME'
> Size = 64
> end
> object SessionQryCLIENT_PWD: TStringField
> FieldName = 'CLIENT_PWD'
> Origin = 'SESSION_MGR.CLIENT_PWD'
> Size = 64
> end
> object SessionQrySESSION_STATE: TIntegerField
> FieldName = 'SESSION_STATE'
> Origin = 'SESSION_MGR.SESSION_STATE'
> end
> end
>*****************************************
>
>So my DB aware grid is using the SessionQry to show data in the table
>SESSION_MGR that has field CLIENT_ID as the PK.
>
>The KeyLinks of the SessionQry is set to CLIENT_ID and
>KeyLinksAutoDefine is set to true.

That looks OK.


>When user is editing in the grid, it is possible that they are editing
>one record and then realize they don't want this record at all, so
>they click the delete button to delete it.

Do you mean "editing" or "inserting"? If the scenario is that they call
Insert, enter some data and then call Delete on that record, then there is
nothing to delete and IBO will return the "Record not located"
exception. In your BeforeDelete code, you could simply intercept that
exception, test for the State, and silently call Cancel if the State is
dsInsert.

Or, better, you could pre-empt the exception condition altogether (sorry
for the Pascal...)

if Dataset.State = dsInsert then
Dataset.Cancel
else
Dataset.Delete;

Is the whole of the story, though? Here's the client code you provided
originally:

> >HolDBView->DataController->DataSource->DataSet->Delete();

What are these other objects?

Helen