Hi wise people,
Has anyone encountered the Crystal Reports problem I describe below?
If so, how did you solve it? It seems that every article posted on
google regarding CR and logon problems is still unanswered. I think
I'm cursed.
I originally created a crystal report which connects to a sql server
server db on the same dev machine and it worked just fine. I tried to
move it to another computer, but now I have to connect to an Oracle
database which resides on another server. So, I created a DSN called
myDSN, and changed my report to use the new DSN. I made sure that I
set the database name to "" (empty string) as specified by the Crystal
Support website: see
(http://support.businessobjects.com/l.../c2010371.asp).
Unfortunately I keep getting a logon failure.
Any ideas about this problem?
I appreciate your help.
Max.
Here is my code:
'=========================BEGIN WEB FORM CODE ===============
Imports System.Data
Imports Microsoft.ApplicationBlocks.Data
Imports Microsoft.ApplicationBlocks.ExceptionManagement
Imports System.Data.OracleClient
Imports System.Text
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class rptSSCrystal
Inherits mywebapp.BaseReport
Protected WithEvents CrystalReportViewer1 As
CrystalDecisions.Web.CrystalReportViewer
Private oRpt As rptTestCR = New rptTestCR()
Private mStartDate As String = "14-01-2004 07:00:00" 'Oracle
format
Private mEndDate As String = "15-01-2004 07:00:00" 'Oracle
format
#Region "SQL Statements"
Dim mstrSQL As String = "SELECT datetime, department, reason,
oper_comment " _
& "FROM Table1 "
#End Region
#Region "Public properties"
Private Property StartDate()
Get
Return mStartDate
End Get
Set(ByVal Value)
mStartDate = Value
End Set
End Property
Private Property EndDate()
Get
Return mEndDate
End Get
Set(ByVal Value)
mEndDate = Value
End Set
End Property
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim ds As DataSet = New DataSet
Try
'Add the where clause to the sql statement
mstrSQL += " WHERE datetime >= to_date('" & Me.StartDate &
"','DD-MM-YYYY HH24:MI:SS')" & " AND datetime <= to_date('" &
Me.EndDate & "','DD-MM-YYYY HH24:MI:SS')" & " ORDER BY datetime DESC"
'Get the dataset
ds = OracleHelper.ExecuteDataset(Me.ConnectionString,
CommandType.Text, mstrSQL)
'Use Report Engine object model to pass populated
dataset
' to report
oRpt.SetDataSource(ds)
'Set permissions
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim CrTables As Tables
Dim CrTable As Table
Dim TableCounter
With crConnectionInfo
.ServerName = "myDSN"
'If you are connecting to Oracle there is no
'DatabaseName. Use an empty string.
'For example, .DatabaseName = ""
.DatabaseName = ""
.UserID = "myID"
.Password = "myPwd"
End With
CrTables = oRpt.Database.Tables
'Loop through each table in the report and apply the
'LogonInfo information
For Each CrTable In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
'CrystalReportViewer1.DisplayToolbar = False
CrystalReportViewer1.DisplayGroupTree = False
'Set the report source to the report component.
CrystalReportViewer1.ReportSource = oRpt
Catch exp As Exception
'Publish the error to the log file
ExceptionManager.Publish(exp)
'Add an error to the page Errors collection
Me.ErrorsList.Add("An error occured while connecting to
the database. Please contact the system administrator.")
End Try
End Sub
#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()
End Sub
#End Region
End Class
'=========================END WEB FORM CODE ===============