on 09-29-2008 10:08 PM
I am trying to export reports to PDF files in VB using a simple loop. Usually it works fine but there are times when I get 0 records in the report. The loop is set up so that there is always data available for the report. I can put breaks in the code and force it to work properly but running at full tilt it fails.
I'm using Cryatal v9 sp7.
I tried Cryatal XI and the results were worse and included new errors to contend with so I went back to 9.
Any help would be appreciated.
Hi Les,
This sounds like you are using resultsets. If that is the case, it may be that the computer can't keep up with the constant shifting in and out of memory of the data.
Some options to consider:
1. Use a direct connection to the database instead
2. Use Saved Data
3. Put a delay in your program.
Regards,
Shawn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks to all for the help.
I have changed over to SQL using ODBC and the problem no longer exists.
It appears that the entire issue was somehow due to MS Access? No matter what type of connection I used to access the table (ODBC, DAO, ADO, OLEDB, DE...) the process stilled failed. I believe that the table either closes to slowly or not at all for some reason.
If anyone ever runs across an answer for this please let me know as I would like to use Access in the future for portability.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What I mean by direct database connection is that there isn't an intermediate step for the data.
e.g.
Direct Connection:
-Report uses an OLEDB connection to connect to a SQL Server Database and read a Non-Temporary Database Table
-Report uses a ODBC connection to an Oracle server and calls a stored procedure which returns the data back
Indirect Connection:
-Report is based off of a temp table which needs to be generated by a call to a stored procedure
-Report is based off of recordsets which need to be populated and then passed to the report
Regards
Shawn
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, Les;
I think you are correct, it does not actually get the data when it fails or the code I suggested would work as expected.
Crystal Reports expects the table to be closed when the report accesses the database. The report will open the table as needed.
If you are creating a temp table be sure it is complete and closed before running the report.
What code to you use to connect to the data at runtime?
When you say DAO are you referring to the native driver to Access in the report? I recommend oledb or odbc to Access rather than the older native drivers.
Elaine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your replys....
Shawn - not sure what you mean by direct connection or saved data.
I have tried delay loops and timers without success.
Ludek - I am destroying the report as well as the application
Elaine - I'm pretty sure that it is a timing issue as it seems that the larger reports are the ones that fail most often. I can put breaks in the code an make them process correctly every time. Average report size is 200 - 400 records. I've tried both DAO and the Data Environment connections. I will try the others. The data should be complete as I close and re-open the table before running the report. It acts like the report can't gain access to the table, I either get the full report or 0 lines. Nothing in between.
I did try the numPages code you suggested but that code in I get memory read errors.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, Les;
This sounds like a timing issue.
How does the report connect to the data - OLEDB, ODBC, classic ADO?
Are you sure the data is complete before trying to export? How many records would you expect on average?
You might want to try adding the following line before you export:
Dim numPages As Integer
numPages = Report.PrintingStatus.NumberOfPages
That will force the report to complete before exporting.
Let me know what you find.
Elaine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Shawn's suggestions are great. Also, ensure you are destroying the report objects once you are done with them;
myReport = nothing
Ludek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.