WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Crystal Reports

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Crystal Reports Problem


Question:

The following code works with Crystal Reports 8.5. However, the code does not work with Crystal 10. Can anyone provide some suggestions?
Report = IniReadPvt ('CrysArch', 'Report',' ', 'C:\Parameter.ini')
Destination = IniReadPvt ('CrysArch', 'Destination',' ', 'C:\Parameter.ini') 

;write pdf file
cra = objectopen("CrystalRuntime.Application")
cra.LogOnServer("PDSODBC.DLL","C.dsn","C:\","","")
cra.LogOnServer("PDSODBC.DLL","CWAcctg.dsn","G:\CWACCTG\","","")
cra.LogOnServer("PDSODBC.DLL","cwslib.dsn","G:\cwslib\","","")

;open the saved report
crr = cra.OpenReport(Report)

cre = crr.ExportOptions
hfile = Destination

cre.DestinationType = 1 ;diskfile
cre.FormatType = 31 ;24=html 31=pdf
cre.DiskFileName = Destination
cre.PDFExportAllPages
crr.Export(@false)

objectclose(cre)
objectclose(crr)
objectclose(cra) 
I receive Error 1261: Ole:Exception On Line:
crr.Export(@False)

Answer:

You may want to check the wwwbatch.ini file in your "windows" or "winnt" directory for additional error information. Since you did not specify which version of WB you are using, it is a little difficult to predict what you will find in the file.

The OLE exception can indicate that the object is unhappy with some aspect of one or more of the parameters that you passed to any of the methods preceding the call to the "export" method. Because of a lack of knowledge of the Crystal Reports object model, I will not attempt to guess which is the offending parameter.

Check if the script is successfully reading the Report and Destination values from the 'c:\Parameter.ini' file.

DebugTrace is useful.

User Reply:

The script is finding the report and destination values.

I have found something: Before my original post, I unsucessfully tried the script using several different reports. However, I just stumbled upon a report with which the original script does work. I'm directing my efforts towards determining the difference between the report that works and the reports that do not.....

MORE: One of my problems was a Crystal v10 report with a v8.5 subreport. The subreport was only a small portion of the whole report, and therefore easy to miss.


Question:

I have the same problem as described, did you find a solution to 1261 OLE Exception when crr.export(@false) is encountered?

Answer:

Upon error check the wwwbatch.ini file in your "windows" or "winnt" directory for additional error information. What does it say?

User Reply:

I discovered that the problem was not due to the Winbatch script. The following winbatch script works fine with either v10 or v8.5. The problem that I was experiencing was due to a Crystal report v10 with a Crystal report v8.5 embedded in the v10 report (a subreport).
============================================
Report = IniReadPvt ('CrysArch', 'Report',' ', 'C:\Parameter.ini')
Destination = IniReadPvt ('CrysArch', 'Destination',' ', 'C:\Parameter.ini') 

;write pdf file
cra = objectopen("CrystalRuntime.Application")
cra.LogOnServer("PDSODBC.DLL","C.dsn","C:\","","")
cra.LogOnServer("PDSODBC.DLL","CWAcctg.dsn","G:\CWACCTG\","","")
cra.LogOnServer("PDSODBC.DLL","cwslib.dsn","G:\cwslib\","","")

crr = cra.OpenReport(Report)
cre = crr.ExportOptions
cre.DestinationType = 1 ;diskfile
cre.FormatType = 31 ;24=html 31=pdf(hopefully)
cre.DiskFileName = Destination
cre.PDFExportAllPages
crr.Export(@false)

objectclose(cre)
objectclose(crr)
objectclose(cra)
============================================ 


Question:

Now I'm having this problem too: Crystal 9 crashes on the crr.Export method call.

Here's the thing: I don't know what changed!

If I attempt to run the exe compiled many months ago, it runs fine. But if I run it from studio, or compile it again, it fails on the export with: "failed to login user blah blah".

Versions of crystal are same, winbatch program same, can't figger what's different!

I know there's nothing here to go on, just thought I'd chip in with the fact that I too am seeing something funny on the crystal Export method.

Answer:

Post the contents of the wwbatch.ini file. It may give some indication of the problem....

User Reply:

I deleted wwwbatch.ini, then ran program. It now shows:
[COM Exception]
Crystal Reports ActiveX Designer=Logon failed.
Details: 28000:[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'worker'.
[COM Sub-system]
Function=InvokeMember
ErrorCode=9 (0x80020009)
ErrorDesc=Exception occurred.
"worker" is the user name, specified earlier in the LogOnServer call. I know it looks like a simple bad password, but I swear I've tested for that. The same user/pass works well when specified directly within crystal, in the older exe, and other situations. I do know that it sees the sql server because if I intentionally misspell the database name, I get a different error.

WAIT A MINUTE .... MIGHT HAVE SOMETHING...

I GOT IT. The user above was right ==> it's all about subreports. In his case, his nested subreport was from ver8.5, but running inside a ver10.0 report.

In my case, the subreport is from *an earlier setting of the ODBC DSN*. If the DSN is set back the was it was when the report was compiled, it runs OK.

In other words, the main report supports changing DSN info at runtime, but the nested subreports do not.

I can make this program run fine, if I use the old DSN settings. The "thing that changed" was the definition of the ODBC DSN.

Thanks for everyone's help. I would have wandered in the weeds for days without your pointed questions.


Article ID:   W16578
File Created: 2005:02:18:12:21:32
Last Updated: 2005:02:18:12:21:32