Solved

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

Posted on 2004-09-07
6
1,451 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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 …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

11 Experts available now in Live!

Get 1:1 Help Now