SQL Server Performance Forum – Threads Archive
getting traceid parameter output using ADO
Hi,<br /> I am in a process of creating a trace event class using ADO . These are the statements to create a trace event.<br /><br /> –>DECLARE @TraceIdOut int <br /><br /> –>Exec sp_trace_create @traceid= @TraceIdOut OUTPUT , @options = 2 <br /> ,@tracefile =N’C
Exec sp_trace_create @traceid= @TraceIdOut OUTPUT , @options = 2 ,@tracefile =N’C:xx.139318214.trc’
PRINT @TraceIdOut");<br /><br /><br />The statement is getting executed propely and I am trace event is being created in the sql server 2005 . <br /><br />NOw the problem is I dont know how to retrieve the returned trace Id from the record set. <br /><br />Any suggessions regarding this will be highly appreciated.<br /><br />Thanks in advance.<br /><br /><br /><br /><br /> <br />
The problem is, you are PRINTing the traceid. PRINTed output is handled differently by ADO, I think its returned in the ErrorMessage Collection (or something similar, I dont remember). Unless you have a good reason to PRINT it, Id recommend you simply SELECT it, then you can pick it up from ADO as a normal resultset.
Dear Chappy ,<br /> I used select statement (select @TraceIdOut[TraceId]) to return the value. I could get the value using recordSetPtr->Fields->Items["TraceId".<br /><br />Thanks for your help chappy <img src=’/community/emoticons/emotion-1.gif’ alt=’

]]>