Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-07
6
Medium Priority
?
1,796 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 101

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 500 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
Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

 
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 101

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

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 …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

916 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