Solved

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

Posted on 2004-09-07
6
1,617 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 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