Results 1 to 5 of 5

Thread: (Logon failed) ASP .NET and Crystal Report Viewer

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    65

    (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

  2. #2
    Lively Member
    Join Date
    Aug 2002
    Location
    outerspace
    Posts
    126
    I also have recieved this error on ocasion. I was thinking that it was caused because a liscnence wasnt available for that user. But Ive seen other errors for when that happens so Im not sure why. Maybe crystal descions site has some sort of documentation on this error
    "All those who wonder are not lost" -j.r.r tolkien

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    65
    Hi,

    I found the answer here
    http://www.dotnetjunkies.com/tutoria...tutorialid=453

    Thank you,

    Trung Luu

  4. #4
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612
    Trungluu, I tried what they said to do at the link you provided. I am still getting a log on error.

    Could you take a look at my code and tell me if you see anything wrong?

    VB Code:
    1. Imports CrystalDecisions.CrystalReports.Engine
    2. Imports CrystalDecisions.Shared
    3.  
    4. Public Class CigUnitsProcess
    5.     Inherits System.Web.UI.Page
    6.  
    7. #Region " Web Form Designer Generated Code "
    8.  
    9.     'This call is required by the Web Form Designer.
    10.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    11.  
    12.     End Sub
    13.  
    14.     Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    15.         'CODEGEN: This method call is required by the Web Form Designer
    16.         'Do not modify it using the code editor.
    17.         InitializeComponent()
    18.     End Sub
    19.  
    20. #End Region
    21.  
    22.     Dim crpt As CigUnitsRpt
    23.     Dim myTable As CrystalDecisions.CrystalReports.Engine.Table
    24.     Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer
    25.     Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo
    26.  
    27.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    28.         crpt = New CigUnitsRpt()
    29.         For Each myTable In crpt.Database.Tables
    30.             myLogin = myTable.LogOnInfo
    31.             With myLogin.ConnectionInfo
    32.                 .ServerName = "Brutus"
    33.                 .UserID = "User"
    34.                 .Password = "Pass"
    35.                 .DatabaseName = "Daily"
    36.             End With
    37.             myTable.ApplyLogOnInfo(myLogin)
    38.         Next
    39.         CrystalReportViewer1.ReportSource = crpt
    40.         CrystalReportViewer1.DataBind()
    41.         If Not IsPostBack Then
    42.  
    43.         End If
    44.     End Sub
    45.  
    46. End Class

    Thanks
    David Wilhelm

  5. #5
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Indiana
    Posts
    612
    Well, something weird happened. I deleted the report and re-created it and now there's no logon error.

    Oh well, as long as it works.... lol
    David Wilhelm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width