Solved

Logon Failed while exporting (Using Dataset)

Posted on 2004-04-22
7
1,296 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
[X]
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
  • 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: 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 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 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 101

Expert Comment

by:mlmcc
ID: 11001899
Glad I could help

mlmcc
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 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