Hello.
Using:
CE10 & CR10
MS SQL
OS = Win2003 Server
In the past, using sample script from BO, we've been able to print a report using a batch file.
Now we are getting SQL login errors using this same method on Win2003 and MS SQL. I figured out where in my ASP I had to Login to SQL, but can't find it when using this .vbs below. Has anybody been here before?
Is there property that needs to have the DB login? Looking at the script below it looks like I need to log into the oRpt. object but can't find the syntax(!)
I've searched this forum before posting this question, but no luck.
Any advice?
Here are parts of the .vbs script that has been working for us for a long time. This is a script available from BO...
'<PACKAGE>
'<JOB ID=PrtRpt>
'<SCRIPT LANGUAGE='VBScript">
Option Explicit
dim oApp, oRpt, oPageEngine
dim oArgs, i
dim DriverName, PrinterName, PortName
PrinterName = "P1"
PortName = "IP_nnn.nn.nnn.nnn"
Set oApp = WScript.CreateObject("CrystalRuntime.Application")
Set oArgs = Wscript.Arguments
'Create obj for specified report file
Set oRpt = oApp.OpenReport(oArgs.Item(0))
oRpt.MorePrintEngineErrorMessages = False
oRpt.EnableParameterPrompting = False
oRpt.DiscardSavedData
'Pass on any Parameters
for i=1 to oArgs.Count-1
oRpt.ParameterFields(i).AddCurrentValue(oArgs.Item(i))
next
oRpt.ParameterFields(oArgs.Count).AddCurrentValue("333")
'tell report to run: get it's data from the DB
On Error Resume Next
oRpt.ReadRecords
If Err.Number <> 0 Then
WScript.Echo "Error " & Err.Number & ": " & Err.Description & " has occured reading records."
Else
If IsObject(oPageEngine) Then
set oPageEngine = nothing
End If
set oPageEngine = oRpt.PageEngine
End If
'select the printer to go to
oRpt.SelectPrinter DriverName, PrinterName, PortName
If Err.Number <> 0 Then
WScript.Echo "oRpt SelectPrinter failed with error [" & Err.Number & ": " & Err.Description & "]<br>"
end if
'Print the report directly
oRpt.PrintOut False
If Err.Number <> 0 Then
WScript.Echo "oRpt Printout failed with error [" & Err.Number & ": " & Err.Description & "]<br>"
end if
Cleanup
Function Cleanup
Set oArgs = nothing
Set oPageEngine = nothing
Set oRpt = nothing
Set oApp = nothing
WScript.Quit
End Function
'</SCRIPT>
'</JOB>
'</PACKAGE>
Using:
CE10 & CR10
MS SQL
OS = Win2003 Server
In the past, using sample script from BO, we've been able to print a report using a batch file.
Now we are getting SQL login errors using this same method on Win2003 and MS SQL. I figured out where in my ASP I had to Login to SQL, but can't find it when using this .vbs below. Has anybody been here before?
Is there property that needs to have the DB login? Looking at the script below it looks like I need to log into the oRpt. object but can't find the syntax(!)
I've searched this forum before posting this question, but no luck.
Any advice?
Here are parts of the .vbs script that has been working for us for a long time. This is a script available from BO...
'<PACKAGE>
'<JOB ID=PrtRpt>
'<SCRIPT LANGUAGE='VBScript">
Option Explicit
dim oApp, oRpt, oPageEngine
dim oArgs, i
dim DriverName, PrinterName, PortName
PrinterName = "P1"
PortName = "IP_nnn.nn.nnn.nnn"
Set oApp = WScript.CreateObject("CrystalRuntime.Application")
Set oArgs = Wscript.Arguments
'Create obj for specified report file
Set oRpt = oApp.OpenReport(oArgs.Item(0))
oRpt.MorePrintEngineErrorMessages = False
oRpt.EnableParameterPrompting = False
oRpt.DiscardSavedData
'Pass on any Parameters
for i=1 to oArgs.Count-1
oRpt.ParameterFields(i).AddCurrentValue(oArgs.Item(i))
next
oRpt.ParameterFields(oArgs.Count).AddCurrentValue("333")
'tell report to run: get it's data from the DB
On Error Resume Next
oRpt.ReadRecords
If Err.Number <> 0 Then
WScript.Echo "Error " & Err.Number & ": " & Err.Description & " has occured reading records."
Else
If IsObject(oPageEngine) Then
set oPageEngine = nothing
End If
set oPageEngine = oRpt.PageEngine
End If
'select the printer to go to
oRpt.SelectPrinter DriverName, PrinterName, PortName
If Err.Number <> 0 Then
WScript.Echo "oRpt SelectPrinter failed with error [" & Err.Number & ": " & Err.Description & "]<br>"
end if
'Print the report directly
oRpt.PrintOut False
If Err.Number <> 0 Then
WScript.Echo "oRpt Printout failed with error [" & Err.Number & ": " & Err.Description & "]<br>"
end if
Cleanup
Function Cleanup
Set oArgs = nothing
Set oPageEngine = nothing
Set oRpt = nothing
Set oApp = nothing
WScript.Quit
End Function
'</SCRIPT>
'</JOB>
'</PACKAGE>