Hi everyone,
We are using Crystal Reports for .net in our web app. At design time, the connection is defined in the report using the OLE DB provider for SQL Server.
The issue occurs in the code-behind of the webfor1.aspx, while passing the LogOn information to the Crystal Report Document object. VS.net hoighlights and shows error msg at the line
crDatabase = crReportDocument.Database
The code is:
===================================================
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
Public Class report_test
Inherits System.Web.UI.Page
Protected WithEvents crRptViewer As CrystalDecisions.Web.CrystalReportViewer
'CR Variables
Dim crReportDocument As report_test
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
'Create an instance of the strongly-typed report object
crReportDocument = New report_test()
crConnectionInfo = New ConnectionInfo()
With crConnectionInfo
.ServerName = "DEVSERVER1\DEVSERVER1" 'physical server name
.DatabaseName = "pubs"
.UserID = "sa"
.Password = "mypwd"
End With
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
'Set the viewer to the report object to be previewed.
crRptViewer.ReportSource = crReportDocument
End Sub
================================================
Am I missing something in the code? Any help is appreciated.
Thanks in advance.
We are using Crystal Reports for .net in our web app. At design time, the connection is defined in the report using the OLE DB provider for SQL Server.
The issue occurs in the code-behind of the webfor1.aspx, while passing the LogOn information to the Crystal Report Document object. VS.net hoighlights and shows error msg at the line
crDatabase = crReportDocument.Database
The code is:
===================================================
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
Public Class report_test
Inherits System.Web.UI.Page
Protected WithEvents crRptViewer As CrystalDecisions.Web.CrystalReportViewer
'CR Variables
Dim crReportDocument As report_test
Dim crTableLogOnInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Dim crDatabase As Database
Dim crTables As Tables
Dim crTable As Table
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
'Create an instance of the strongly-typed report object
crReportDocument = New report_test()
crConnectionInfo = New ConnectionInfo()
With crConnectionInfo
.ServerName = "DEVSERVER1\DEVSERVER1" 'physical server name
.DatabaseName = "pubs"
.UserID = "sa"
.Password = "mypwd"
End With
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
'Set the viewer to the report object to be previewed.
crRptViewer.ReportSource = crReportDocument
End Sub
================================================
Am I missing something in the code? Any help is appreciated.
Thanks in advance.