Solved

Logon failed.CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.

Posted on 2004-09-07
6
1,487 Views
Last Modified: 2008-01-09
I am trying to export Crystal reports to PDF. I am using VB .NET. I keep getting the following error:
Logon failed.
Description: CrystalDecisions.CrystalReports.Engine.LogOnException: Logon failed.

and this is the code I am using. Any suggestiong will be appreciated.
    Private Sub PDF_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PDF_Button.Click

        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
        Dim myDiskFileDestinationOptions As CrystalDecisions.Shared.DiskFileDestinationOptions
        Dim myExportFile As String
        Dim myReport As New SurgeReportDetails
        myExportFile = "C:\WINDOWS\Temp\PDF" & Session.SessionID.ToString & ".pdf"
        myDiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions
        myDiskFileDestinationOptions.DiskFileName = myExportFile
        myExportOptions = myReport.ExportOptions
        With myExportOptions
            .DestinationOptions = myDiskFileDestinationOptions
            .ExportDestinationType = .ExportDestinationType.DiskFile
            .ExportFormatType = .ExportFormatType.PortableDocFormat
        End With
        myReport.Export()
        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/pdf"
        Response.WriteFile(myExportFile)
        Response.Flush()
        Response.Close()
        'Remove the file from the Server
        System.IO.File.Delete(myExportFile)
 

    End Sub
0
Comment
Question by:stevetheski
6 Comments
 
LVL 4

Author Comment

by:stevetheski
ID: 11998072
More Error details:
Source Error:


Line 89:             .ExportFormatType = .ExportFormatType.PortableDocFormat
Line 90:         End With
Line 91:         myReport.Export()
Line 92:         Response.ClearContent()
Line 93:         Response.ClearHeaders()
 

Source File: c:\inetpub\wwwroot\WebLiloReports\LiloSurgeReportDetails.aspx.vb    Line: 91

Stack Trace:


[LogOnException: Logon failed.]
   .F(String       , EngineExceptionErrorID 
)
   .A(Int16 , Int32 )
   .@(Int16 )
   CrystalDecisions.CrystalReports.Engine.FormatEngine.Export(ExportRequestContext reqContext)
   CrystalDecisions.CrystalReports.Engine.FormatEngine.Export()
   CrystalDecisions.CrystalReports.Engine.ReportDocument.Export()
   WebLiloReports.LiloSurgeReportDetails.PDF_Button_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebLiloReports\LiloSurgeReportDetails.aspx.vb:91
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()

 
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 11998286
Generally that means you need to pass logon information to the report for the database.

Have you looked at these examples
http://support.businessobjects.com/communityCS/FilesAndUpdates/vbnet_web_samples.exe.asp

mlmcc
0
 
LVL 10

Accepted Solution

by:
ebolek earned 125 total points
ID: 12000054
this is how i do it. If you need explanation let me know. It is in C#.

Regards
Emre

private void setlogoninfo(CrystalDecisions.CrystalReports.Engine.ReportDocument myreport)
{
CrystalDecisions.Shared.TableLogOnInfo MyLogonInfo;
foreach(CrystalDecisions.CrystalReports.Engine.Table MyTable in myreport.Database.Tables)
{
MyLogonInfo = MyTable.LogOnInfo;
if (MyTable.Name == "")
{
MyLogonInfo.ConnectionInfo.UserID = this._username;
MyLogonInfo.ConnectionInfo.Password = this._password;
MyLogonInfo.ConnectionInfo.ServerName  = this._servername;  
MyLogonInfo.ConnectionInfo.DatabaseName = this._databasename ;              
}
else
{
MyLogonInfo.ConnectionInfo.UserID = this._username;
MyLogonInfo.ConnectionInfo.Password = this._password;
MyLogonInfo.ConnectionInfo.ServerName  = this._servername;  
MyLogonInfo.ConnectionInfo.DatabaseName = this._databasename ;
}
MyTable.ApplyLogOnInfo(MyLogonInfo);                    
MyTable.Location = MyTable.Location.Substring(MyTable.Location.LastIndexOf(".")+1);  
                   
}
}

         
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Expert Comment

by:ebolek
ID: 12193637
Glad to help

Regards
Emre
0
 

Expert Comment

by:Remulac
ID: 13502140
I tried the above code from Ebolek and I get "Invalid Table Number" on the line:

MyTable.Location = MyTable.Location.Substring(MyTable.Location.LastIndexOf(".")+1);

Why would my code be different?  
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 13502737
Remulac
How about asking your own question and posting the code with an explanation of the problem.

mlmcc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now