AV when calling RecordCount

David

Member
I've written some code that uses RecordCount in the AfterQuery event of an OracleDataset. It works, but I'm facing an Access Violation when I do an initial query from the FormCreate event. Any idea of what's wrong?

------------------
 
I forgot to mention: it works fine if I do the query from other events, like a buttonclick, and the table is returning records. The query itself is valid.
 
Basically you have answered your own question. Never use the FormCreate and FormDestroy events. Their semantics are poorly defined, and have even changed over the years, as can be seen in the OldCreateOrder kludge.

------------------
Frans
 
Now I also get AV from other events...

basically I want to detect if an Oracle Dataset has returned any row or it has returned zero rows. Can you show me some code doing that? RecordCount doesn't seem to be reliable.
 
I'm not sure why you get AV's, that should of course not occur. It's difficult to say what the cause might be though.

If you can't fix the AV, you could consider using the TOracleDataSet.CountQueryHits function. The value of the RecordCount property depends on the QueryAllRecords property, so it may return the records that have been fetched "so far".

------------------
Marco Kalter
Allround Automations
 
Back
Top