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

Automation object difficulties with Crystal Reports

Status
Not open for further replies.

jhall156

Programmer
Joined
Aug 27, 2001
Messages
711
Location
US
I am in dire need of sp_OAMethod help.
Here is my T-SQL script:

DECLARE @Application int
DECLARE @Report int
DECLARE @PrinterDriver varchar(255)
DECLARE @PrinterName varchar(255)
DECLARE @PrinterPort varchar(255)
DECLARE @PrinterInfo int


DECLARE @hr int
DECLARE @src varchar(255), @desc varchar(255)
EXEC @hr = sp_OACreate 'CrystalRuntime.Application', @Application OUT
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @Application, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END

PRINT @Application

EXEC @hr = sp_OAMethod @Application, 'OpenReport', @Report OUT, 'c:\temp\TestReport.rpt', 1
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @Application
RETURN
END
PRINT @Report




EXEC @hr = sp_OAMethod @Report, 'SelectPrinter', null,'hpbf032g.dll','\\apps\IS General','HPLJ8150'
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @Report
RETURN
END

EXEC @hr = sp_OAGetProperty @Report, 'PrinterInfo', @PrinterInfo OUT
EXEC @hr = sp_OAGetProperty @PrinterInfo, 'DriverName', @PrinterDriver OUT
EXEC @hr = sp_OAGetProperty @PrinterInfo, 'PrinterName', @PrinterName OUT
EXEC @hr = sp_OAGetProperty @PrinterInfo, 'PortName', @PrinterPort OUT
PRINT @PrinterDriver
PRINT @PrinterName
PRINT @PrinterPort

EXEC @hr = sp_OAMethod @Report, 'PrintOut', null
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @Report
RETURN
END

EXEC @hr = sp_OADestroy @Report
IF @hr <> 0
BEGIN

EXEC sp_OAGetErrorInfo @Report
RETURN
END

EXEC @hr = sp_OADestroy @Application
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @Application
RETURN
END

All segments work and return expected results until I
invoke the PrintOut method. That causes the Query Analyzer to lock up. The automation object works fine in VB. It is also interesting to note that the Preview method generates an error which states &quot;Output values of type Object are not allowed in result sets.&quot; which seems to indicate that the automation server is unable to perform the task of opening a preview window within the context of SQLServer. It seems perfectly reasonable to me that this should be a fairly easy task. I want to generate daily report data with a SQLAgent job and then print/export/email those management reports and this is all functionality contained within Crystal Reports RDC (Report Design Component) automation object. Any suggestions are welcome.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top