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

x
?
Solved

Logon Failed while exporting (Using Dataset)

Posted on 2004-04-22
7
Medium Priority
?
1,310 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 101

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 101

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
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.

 
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 101

Accepted Solution

by:
mlmcc earned 375 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 101

Expert Comment

by:mlmcc
ID: 11001899
Glad I could help

mlmcc
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

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…
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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

927 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