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 while exporting (Using Dataset)

Posted on 2004-04-22
7
1,283 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

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

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 …
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

860 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