Crystal Reports & VB6 - Retrieving SQLQueryString property

We are trying to retrieve the SQLQueryString from a report and getting an emptystring.
When stepping through in code it works fine and puts the string into a variable but in compiled app it fails to retrieve value.

Any ideas (or maybe a better question)

Ray
rfoconnorAsked:
Who is Participating?
 
moduloConnect With a Mentor Commented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0
 
mlmccCommented:
Is there a reason to retrieve the string?

What code are you using to retrieve the string?

mlmcc
0
 
vidruCommented:
Can you post the code you're using?  Also, your version of Crystal, DB, and connectivity would be helpful.

I just ran a quick test using an ODBC connection to the CR Extreme sample db using CR8.5/VB6/RDC, and was able to successfully retreive the SQLQueryString from the report.  I did notice that when I was trying to access the SQLQueryString property, it would invoke the parameter window.

For example, this would invoke the parameter window once:
  Set rpt = cApp.OpenReport("c:\regions.rpt")
  strQry = rpt.SQLQueryString
  CRViewer1.ReportSource = rpt
  CRViewer1.ViewReport

This will cause the parameter to be invoked twice, but if two different values are entered, the report will reflect the first (invoked from ViewReport), but the SQLQueryString will reflect the second:
  Set rpt = cApp.OpenReport("c:\regions.rpt")
  CRViewer1.ReportSource = rpt
  CRViewer1.ViewReport
  strQry = rpt.SQLQueryString

-dave
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
rfoconnorAuthor Commented:
retrieving the string to modify it.

code as follows
'==========================================
sTableName = objCRTable.Location
if sTableName = "" then
    ' do error stuff and exit
end if

sSQL = objCRRpt.SQLQueryString
if sSQL = "" then
    ' do error stuff and exit
end if

' code to replace the tablename with the name of a CSV file generated from a query earlier
'==========================================

The problem occurs with line
sSQL = objCRRpt.SQLQueryString

When running the compiled object and occaisionally when running in debug sSQL is empty.
When stepping through the code more slowly it is populated properly every time.

Almost as if "objCRRpt.SQLQueryString" is running asynchronously



0
 
frodomanCommented:
Could be waiting for a response to build the SQL.  Have you tried simply putting a small "wait" or "sleep" in front of this line of code?
0
 
rfoconnorAuthor Commented:
We considered this but don't feel keen on putting in a "sleep" or similar with no way of knowing when the property has been returned.  May have to though.
0
 
rfoconnorAuthor Commented:
Did try putting a wait loop in but to no avail.

The problem seems to be opening the template.  Sometimes it works and sometimes it doesn't.
0
 
rfoconnorAuthor Commented:
Hi there

I found the answer by completely taking down Crystal Reports and re-installing it.

ALl I can think of is that there was a rogue DLL from an older version hanging around
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.