Hello,
I have an ADO based C++ application (see code below) that is running
the sql statements (see statements below) in sequence on SQL Server 7.
SQL STATEMENTS
--------------
DECLARE @queue_handle int
DECLARE @column_value int
SET @column_value = 1|128|1024|512|8192|4
exec xp_trace_addnewqueue 1000, 5, 95, 90, @column_value,
@queue_handle OUTPUT
exec xp_trace_seteventclassrequired @queue_handle, 12, 1
exec xp_trace_getevents @queue_handle, 1, 1, 100
ADO CODE
--------
TCHAR sql[256] = {0};
stprintf(sql, _T("exec xp_trace_getevents %d, 1, 1, 100\r\n"),
traceid);
_RecordsetPtr pRecordset;
_variant_t RecordCount;
pRecordset = m_pConn->Execute(sql, &RecordCount, 0);
while (!pRecordset->ADOEOF)
{
const TString row
= (const TString)
pRecordset->GetString(adClipString,1,_T("|"),_T("\r\n"),
_T(""));
printf("stmt = %s\n", row.c_str());
}
SAMPLE OUTPUT
--------------
stmt = 12|select * from authors where au_lname <> 'Carson'
|5|MYCOMP1|MS SQL Query Analyzer|su|7/9/2003 2:10:54 PM
stmt = 12|select * from authors where au_lname <> 'Carson'
|5|MYCOMP1|MS SQL Query Analyzer|su|7/9/2003 2:10:55 PM
stmt = 0||0|||| (empty row)
stmt = 0||0|||| (empty row)
stmt = 0||0|||| (empty row)
stmt = 0||0|||| (empty row)
PROBLEM
-------
This program is supposed to capture all sql queries being sent to sql
server and print them out. However, the problem is that sometimes,
instead of displaying captured queries, the program displays null
rows.
Any idea why this is happening?
When I run the same set of SQL (as shown above) in Query Analyzer all
the queries are captured. It is only when the queries are run within
the ADO program that problem starts to occur.
Any help is appreciated. Thanks.