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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I tell if a report is has no Records in C++/VB Code helpful

Status
Not open for further replies.

sparky2708

Programmer
Jul 8, 2002
18
US
How do I use the API to query whether there is any data in the report that I am trying to execute? I tried:

long test = 10;
VARIANT arr;
VariantInit(&arr);
arr = crRpt->GetNextRows(0, &test);

if (test > 0)
crRpt->Export(var);

For some reason "test" is always 1. Even if there are no records it gets set to 1. My logic behind this was that this function would return -1 or 0 if it couldn't fetch any records and a number greater than that if there were rows it could fetch. How else can I do this?
 
Very rough VB code (from a working app):

Dim adors As ADODB.Recordset
Dim strsql As String
Set adors = New ADODB.Recordset
strsql = "SELECT [field name] from [table name]"
'use any field in the table
adors.Open strsql, conn.cnn, adOpenDynamic, adLockOptimistic ' conn has to be open, of course
If adors.EOF ' there are no records
 
Thanks aklein. I thought of doing it this way - just by directly querying the tables. My application deals with executing multiple reports so the tables that I query can't be hardcoded furthermore if I query the tables from the "Report" object it isn't obvious from the report object how the tables that are specified in the report are supposed to be joined and furthermore if a report is based on a stored proc makes it very complicated. In order to avoid all complications all I REALLY need to do is to query the report object directly for data and figure out if it has any. This way I will know whether the report has any rows.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top