Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to access Command Object in ADO execute complete event

Status
Not open for further replies.

jOutPerl

Programmer
Jun 10, 2008
2
ES
Hello,

I want to keep trace of every stored procedure I call using ADO executeComplete event in my ADO connection object (just for loging propourses). My problem is that I can not access any Command property because of const statement in the event prototype just before _Command.

Code:
void __fastcall TDm::ADOCnnClientesExecuteComplete(TADOConnection *Connection,
	  int RecordsAffected, const Error *Error, TEventStatus &EventStatus,
	  [b]const _Command *Command[/b], const _Recordset *Recordset)
{
}
Is there any option to access Command properties (like parameteres names, values, etc. inside this event handler?

Thanks in advance (sorry if my english is not good enough)
 
Have you tried something like:
Code:
AnsiString CmndStr = ADOCommand1->CommandText;


James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
Well, I have tried something like that.
First, tried to upcast, but it didn´t work
Code:
void __fastcall TDm::ADOCnnClientesExecuteComplete(TADOConnection *Connection,
      int RecordsAffected, const Error *Error, TEventStatus &EventStatus,
      const _Command *Command, const _Recordset *Recordset)
{
	TADOCommand *ADOCmd;
	ADOCmd = (TADOCommand*) Command; 
}

Then I tried to use directy _Command
Code:
void __fastcall TDm::ADOCnnClientesExecuteComplete(TADOConnection *Connection,
      int RecordsAffected, const Error *Error, TEventStatus &EventStatus,
      const _Command *Command, const _Recordset *Recordset)
{	
	String strCmd;
	Command->Get_CommandText(strCmd); //strCmd is passed as a reference
}
But Complains Get_CommandText is not a const member function!!
This is actually the problem. In other ADO implementations (.NET or VC++) the event does not have const just in front of _Command


//also tried to create a new Command Object from scratch.
Code:
void __fastcall TDm::ADOCnnClientesExecuteComplete(TADOConnection *Connection,
      int RecordsAffected, const Error *Error, TEventStatus &EventStatus,
      const _Command *Command, const _Recordset *Recordset)
{	
	TADOCommand *ADOCmd2 = new TADOCommand (NULL);
	ADOCmd2->CommandObject = Command; //
	
}

This time i get Cannot convert 'const _Command *' to '_di__Command'
Well, actually I really don´t understand the diference between _Command and TADOCommand. I think, TADOCommand should be some kind of wrapper for the ADO.Command COM object
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top