IDBResultSet question.

Hi,

Is there a way to check if field exists and if field is null in a IDBResultSet?

Thanks in advance,

Omar Zelaya

You can get an IDBResult2 interface, which provides the method GetFieldIndex:

if (ResultSet as IDBResult2).GetFieldIndex('SomeField') <> -1 then ...

For null, you can simply get the value and check if it's a null variant (VarIsNull).

Hi,
I get a undeclared identifier IDBResult2.

Thanks in advance,

Omar Zelaya

Sorry, IDBResultSet2, declared in unit Aurelius.Drivers.Interfaces.

Hi,

Actually this code "if (ResultSet as IDBResult2).GetFieldIndex('SomeField') <> -1 then" instead of returning -1, it throws an exception. I was looking to avoid to use try catch on every field check.

Thanks in advance.

Alternatively you can check if IDBStatement is a IDBDatasetStatement. If it is, you can get the underlying TDataset which then you can use the regular dataset methods like FindField.