(Logon failed) ASP .NET and Crystal Report Viewer
Hi,
I have created an .aspx page that contains a crystal report viewer and this report gets data from a MS SQL Server 2000. But when I run this page I always get the following error, even thought I set a right username and password:
Exception Details: CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.
Source Error:
An unhandled exception was generated during the execution of
the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
This is my codes:
'====================
Imports System
Imports Microsoft.Win32
Public Class simplepage1
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer
#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()
CrystalReportViewer1.ReportSource = GetSampleReportsDir() + "General Business\World Sales Report.rpt"
Call SetLogOnInfo()
CrystalReportViewer1.DataBind()
'Response.End()
End Sub
#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
End Sub
Private Function GetSampleReportsDir() As String
'Get the path VS was installed to
Dim regKey As RegistryKey
Dim dir As String
regKey = Registry.LocalMachine
regKey = regKey.OpenSubKey("Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VS")
dir = regKey.GetValue("ProductDir").ToString()
dir += "Crystal Reports\Samples\Reports\"
GetSampleReportsDir = dir
End Function
Private Sub SetLogOnInfo()
' Set the connection information for the table in the report.
CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.ServerName = "TRUNGPSL"
CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.DatabaseName = "QLRR"
CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.UserID = "sa"
CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.Password = "sa12"
CrystalReportViewer1.LogOnInfo(0).TableName = "Customer"
End Sub
End Class
'===========
Could you please tell me how to resolve this problem?
Thanks in advance,
Trung Luu