Solved

Crystal Reports & VB6 - Retrieving SQLQueryString property

Posted on 2004-09-29
9
587 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:rfoconnor
9 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 12182531
Is there a reason to retrieve the string?

What code are you using to retrieve the string?

mlmcc
0
 
LVL 13

Expert Comment

by:vidru
ID: 12182535
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
 

Author Comment

by:rfoconnor
ID: 12191632
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
 
LVL 42

Expert Comment

by:frodoman
ID: 12192294
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:rfoconnor
ID: 12193901
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
 

Author Comment

by:rfoconnor
ID: 12274588
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
 

Author Comment

by:rfoconnor
ID: 12537525
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
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12572823
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now