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
Solved

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

Posted on 2004-09-07
6
1,544 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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 …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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…

856 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