Solved

Logon Failed while exporting (Using Dataset)

Posted on 2004-04-22
7
1,264 Views
Last Modified: 2007-12-19
I get this popular Logon Failed Error when i'm trying to export a report to pdf format. I'm not using the classic connection. I have a dataset created at run-time and setting the SetDataSource to the dataset generated. It works fine when i view using the viewer but gives "Logon Failed" when i'm trying to export. Here is my code.

        Dim rpt As New crLocationTags()
        Dim ds As New DataSet("authors")

        Dim cn As New SqlClient.SqlConnection("connection string")
        cn.Open()
        Dim cd As New SqlClient.SqlCommand("Select * from authors", cn)
        Dim sa As New SqlClient.SqlDataAdapter(cd)
        sa.Fill(ds, "authors")

        ds.Tables(0).TableName = "authors"
        rpt.Database.Tables(0).SetDataSource(ds)

        Dim strFName As String
        Dim sAppPathName As String
        sAppPathName = ConfigurationSettings.AppSettings("AppPathName")
        strFName = Server.MapPath("/") & sAppPathName & "\Export\" & Session.SessionID & ".pdf"

        Dim oExp As New ExportOptions()
        Dim oDo As New DiskFileDestinationOptions()

        rpt.Load()

        oDo.DiskFileName = strFName
        oExp = rpt.ExportOptions
        oExp.ExportFormatType = ExportFormatType.PortableDocFormat
        oExp.ExportDestinationType = ExportDestinationType.DiskFile
        oExp.DestinationOptions = oDo

        rpt.FormatEngine.PrintOptions.PaperSize = PaperSize.PaperLetter
        rpt.FormatEngine.PrintOptions.PaperOrientation = PaperOrientation.Landscape
        rpt.Export()          ' This is the line i'm getting error on...


Any help is greatly appreciated.

Thanks
Sandeep
0
Comment
Question by:Sandeepk1999
  • 4
  • 3
7 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 10893572
Is this code similar to the code used to open the viewer?

Does the database require a login?

mlmcc
0
 
LVL 4

Author Comment

by:Sandeepk1999
ID: 10893627
When i do this it works fine...
        Dim rpt As New crLocationTags()
        Dim ds As New DataSet("authors")

        Dim cn As New SqlClient.SqlConnection("connection string")
        cn.Open()
        Dim cd As New SqlClient.SqlCommand("Select * from authors", cn)
        Dim sa As New SqlClient.SqlDataAdapter(cd)
        sa.Fill(ds, "authors")

        ds.Tables(0).TableName = "authors"
        rpt.Database.Tables(0).SetDataSource(ds)
       CrystalReportViewer1.ReportSource = rpt

Sandeep
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10895295
The initial report setup seems identical to the viewing one.

Can you export to PDF from the viewer?

What version of CR?

mlmcc
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 4

Author Comment

by:Sandeepk1999
ID: 10896395
I'm using CR included with .NET. I'm getting the error on the export command. I'm using the ASP.NET viewer, it does not include export option.

Sandeep
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 125 total points
ID: 10905244
These may be helpful.  They are for CR9 but CR.Net is similar.

http://support.businessobjects.com/communityCS/FilesAndUpdates/aspxmps9.exe.asp

mlmcc
0
 
LVL 4

Author Comment

by:Sandeepk1999
ID: 10997087
I solved this problem.

I recreated the new dataset and new report then everything worked fine. Then went and compared the what the difference was, and found that one of the field name had a space in my dataset.

Still i dont understand how it worked with viewer and failed during export. And another weird thing was it gave "Logon failed" exception, which drives you to wrong direction.

In short, If anyone gets "Logon Failed" exception look into other mistakes like wrongly type field names, invalid object name, etc.. before digging and and changing the code too much.

mlmcc, Thanks for u r help - I'll award you this points to u for looking and into it.

Sandeep
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 11001899
Glad I could help

mlmcc
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 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

18 Experts available now in Live!

Get 1:1 Help Now