I'm really need some urgent help with this. My enviornment is
Windows Server 2003 (Upgraded from Windows 2K Server), CR10 (
CR9 was uninstalled prior to install of v10)
I had many reports working great through my ASP application, but
since the upgrade, the recordset cannot be read for some reason.
Below is the example code from CR that I modified slightly to
run on SQL Server 2000 (minus all the comments). The table has 2
rows in it. When I try to pass the recordset, the report should
only show 1 record.
What is happening is, EVERYTHING works great, but the dataset
never changes. Any ideas?
Thanks!
'==================================================================
' Begin code
'==================================================================
reportname = "Report1.rpt"
'==================================================================
' ALWAYS REQUIRED STEPS
'==================================================================
If Not IsObject (session("oApp")) Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.10")
End If
Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
End if
On error resume next
Set session("oRpt") = session("oApp").OpenReport(path & reportname, 1)
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
End If
dim mainReportTableCollection, mnTable
Set mainReportTableCollection = Session("oRpt").Database.Tables
For Each mnTable in mainReportTableCollection
With mnTable.ConnectionProperties
.Item("Provider") = "SQLOLEDB"
.Item("Data source") = "myserver"
.Item("Initial Catalog") = "mydatabase"
.Item("User ID") = "myuser"
.Item("Password") = "mypass"
End With
Next
session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False
session("oRpt").DiscardSavedData
'==================================================================
' REPORTING OFF AN ADO RECORDSET OBJECT
'==================================================================
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=SQLOLEDB;User Id=myuser;Password=mypass;server=myserver;Initial Catalog=mydatabase"
set session("oRs") = Server.Createobject("ADODB.Recordset")
session("oRs").ActiveConnection = oConn
strSQL = "select * from application_errors where n_error_key = 1"
Set oRs = oConn.Execute(strSQL)
Set oRptTable = session("oRpt").Database.Tables
oRptTable.SetDataSource oRs, 1
'==================================================================
' MORE ALWAYS REQUIRED STEPS
'==================================================================
On Error Resume Next
session("oRpt").ReadRecords
If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine")) Then
set session("oPageEngine") = nothing
End If
set session("oPageEngine") = session("oRpt").PageEngine
End If
' INSTANTIATE THE REPORT VIEWER
<!-- #include file="SmartViewerActiveX.asp" -->
Windows Server 2003 (Upgraded from Windows 2K Server), CR10 (
CR9 was uninstalled prior to install of v10)
I had many reports working great through my ASP application, but
since the upgrade, the recordset cannot be read for some reason.
Below is the example code from CR that I modified slightly to
run on SQL Server 2000 (minus all the comments). The table has 2
rows in it. When I try to pass the recordset, the report should
only show 1 record.
What is happening is, EVERYTHING works great, but the dataset
never changes. Any ideas?
Thanks!
'==================================================================
' Begin code
'==================================================================
reportname = "Report1.rpt"
'==================================================================
' ALWAYS REQUIRED STEPS
'==================================================================
If Not IsObject (session("oApp")) Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.10")
End If
Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
If IsObject(session("oRpt")) then
Set session("oRpt") = nothing
End if
On error resume next
Set session("oRpt") = session("oApp").OpenReport(path & reportname, 1)
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
End If
dim mainReportTableCollection, mnTable
Set mainReportTableCollection = Session("oRpt").Database.Tables
For Each mnTable in mainReportTableCollection
With mnTable.ConnectionProperties
.Item("Provider") = "SQLOLEDB"
.Item("Data source") = "myserver"
.Item("Initial Catalog") = "mydatabase"
.Item("User ID") = "myuser"
.Item("Password") = "mypass"
End With
Next
session("oRpt").MorePrintEngineErrorMessages = False
session("oRpt").EnableParameterPrompting = False
session("oRpt").DiscardSavedData
'==================================================================
' REPORTING OFF AN ADO RECORDSET OBJECT
'==================================================================
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "Provider=SQLOLEDB;User Id=myuser;Password=mypass;server=myserver;Initial Catalog=mydatabase"
set session("oRs") = Server.Createobject("ADODB.Recordset")
session("oRs").ActiveConnection = oConn
strSQL = "select * from application_errors where n_error_key = 1"
Set oRs = oConn.Execute(strSQL)
Set oRptTable = session("oRpt").Database.Tables
oRptTable.SetDataSource oRs, 1
'==================================================================
' MORE ALWAYS REQUIRED STEPS
'==================================================================
On Error Resume Next
session("oRpt").ReadRecords
If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & Err.Description
Set Session("oRpt") = nothing
Set Session("oApp") = nothing
Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine")) Then
set session("oPageEngine") = nothing
End If
set session("oPageEngine") = session("oRpt").PageEngine
End If
' INSTANTIATE THE REPORT VIEWER
<!-- #include file="SmartViewerActiveX.asp" -->