Question

I am trying to write an ADO Database profiler in Delphi 7. it is part of a Delphi project.

I am using OnExecuteComplete event, but on some PCs i get "MSADO15.DLL" Access Violation error.

I have researched and underestand some win version is incompatible or damaged or has different version..

that AV error happened when i use parameters[i].value property of "Command".. then i decide to write a different type, now i need a refference to an object who called OnExecuteComplete event in ADOConnection. if i can reach it, problem will be solved.

i use "Command" and "Recordset" refferences to compare by all of ADO object who linked by this ADOConnection, but some ADO objects has no Recordset.. is there a way to find who fire that event? like Sender?

Was it helpful?

Solution 2

i solve it! i write 2 derrived classes, from ADOQuery and ADOStoredProc. then i publish Command property of them. by force convert StoredProcedure to new class, i reach to command prop and compare that by command object of event! problem solved! thank you all.

OTHER TIPS

I could not make out if you are in .Net or not, but in .Net it's easy. Use System.Diagnostics.StackTrace to see the whole stack of calls that lead to your event.

For native code there will probably also be a way to get a stacktrace if you compile in debug mode. It's quite some time since I've written Delphi (or Pascal) code. You could also try profiling with the free AQTime standard which works well with Delphi (both native as well as .Net) which also has a call-graph feature.

Only WindowsXP,Windows 2003 has problem with "MSADO15.DLL" Access Violation error after read Parameters[i].Value and show recordset. Windows7 has not this problem. Use WillExecute event - it work fine everywhere. In ExecuteComplete you may get recordsAffected from recordset (RecordsAffected variant work wrong). You can get Parameters[i].Value later if Save Parameters to Variant variable and read it after visual components show recordset - use OnButtonClick for example or Timer event. This BUG not fixed at all Delphi versions - and in DelphiXE2 too..

The Sender should give you a clue, if it is not nil. Cast it to TComponent and use its Name property to find out which component fired it:

ShowMessage((Sender as TComponent).Name);

If Sender is nil, a stack trace might help.

Update

Apparently there is no Sender parameter. In this case, the Connection must be the class that fires it, so get its name and other data. You get enough parameters to find out what is happening.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top