Subject Re: [IBO] is dataset empty
Author Paul Vinkenoog
Hello Gediminas,

>> For a TIB_Cursor, you can use the same strategy:
>> MyCursor->APIFirst();
>> bool CursorEmpty = MyCursor->Eof;

> It would be ok, but I'm working with the generic class (it handles
> cursor & query):
>
> bool CanEdit(TIB_Dataset * pDataset)
> {
> ......
> }
>
> If I would use pDataset->First, then in case with a query, cursor
> would be positioned to the first record - that's bad, so need other
> solution.

You could do this, then:

bool __fastcall CanEdit( TIB_Dataset *pDataset )
{
TIB_BDataset *pBD = dynamic_cast< TIB_BDataset* >( pDataset );
if ( pBD )
{
return ! pBD->IsEmpty;
}
else
{
// either use my "APIFirst & test Eof" trick
// or Luc's "Bof and Eof" test
// ...both on pDataset of course, not on pBD!
}
}

BTW: The fact that the set isn't empty doesn't guarantee that you can
go into edit mode directly! So the function name is a bit misleading.


Greetings,
Paul Vinkenoog