Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8491817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:32:32+00:00 2026-06-10T22:32:32+00:00

In my application I have some code to convert to PDF. In debug mode

  • 0

In my application I have some code to convert to PDF. In debug mode all is good and working but when I test it on then server I keep getting the logon to the database failed. I have no idea why I get the error becase the login and password are 100% ok.

tried 2 ways for the server of sending the report

SetCrystalReportFilePath(Server.MapPath("~/MemberPages/Report.rpt"))
SetPdfDestinationFilePath(Server.MapPath("~/MemberPages/Report_" & Report & ".pdf"))
SetRecordSelectionFormula("{Report.Report_id} =" & ID)
Transfer()



SetCrystalReportFilePath("C:\inetpub\wwwroot\Werkbon.rpt")
SetPdfDestinationFilePath("C:\inetpub\wwwroot\Werkbon_" & werkbonnr & ".pdf")
SetRecordSelectionFormula("{werkbon.werkbon_id} =" & werkbonnr)
Transfer()

Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim oRDoc As New ReportDocument
Dim expo As New ExportOptions
Dim sRecSelFormula As String
Dim oDfDopt As New DiskFileDestinationOptions
Dim strCrystalReportFilePath As String
Dim strPdfFileDestinationPath As String

Public Function SetCrystalReportFilePath(ByVal CrystalReportFileNameFullPath As String)
    strCrystalReportFilePath = CrystalReportFileNameFullPath
End Function

Public Function SetPdfDestinationFilePath(ByVal pdfFileNameFullPath As String)
    strPdfFileDestinationPath = pdfFileNameFullPath
End Function

Public Function SetRecordSelectionFormula(ByVal recSelFormula As String)
    sRecSelFormula = recSelFormula
End Function

Public Function Transfer()
    oRDoc.Load(strCrystalReportFilePath)
    oRDoc.RecordSelectionFormula = sRecSelFormula
    oDfDopt.DiskFileName = strPdfFileDestinationPath
    expo = oRDoc.ExportOptions
    expo.ExportDestinationType = ExportDestinationType.DiskFile
    expo.ExportFormatType = ExportFormatType.PortableDocFormat
    expo.DestinationOptions = oDfDopt
    oRDoc.SetDatabaseLogon("databasename", "password")
    oRDoc.Export()
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:32:34+00:00Added an answer on June 10, 2026 at 10:32 pm

    Crystal is very particular when swapping in and out connection information (especially with sub-reports if you have any). It’s always been a sore spot that they haven’t really made any better over the years. I have a blog entry I’ve shared that has extension methods I created (in VB.Net) to easily load and swap in new connections (typically I use ADO for the connection in the report). The extension methods can be found in this link (and below is an example of how to use them, ignore the System.Diagnostics line if you’re using this from ASP.NET). Hope this helps.

    http://www.blakepell.com/Blog/?p=487

        Using rd As New ReportDocument
            rd.Load("C:\Temp\CrystalReports\InternalAccountReport.rpt")
            rd.ApplyNewServer("serverName or DSN", "databaseUsername", "databasePassword")
            rd.ApplyParameters("AccountNumber=038PQRX922;", True)
            rd.ExportToDisk(ExportFormatType.PortableDocFormat, "c:\temp\test.pdf")
            rd.Close()
        End Using
    
        System.Diagnostics.Process.Start("c:\temp\test.pdf")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that attempts to test whether my application is running with
I have some old code (an old but still maintained VB6 application) that from
I have to modify some code in a application I am working on that
I have some code the requires the application to be completely loaded and compiled
I have written some code for playing a .wav through my application. Now I
I have some VBA code that needs to talk to a running c# application.
In my application there is language detection. Languages have some identification code like en
I have an application written in C# that invokes some C code as well.
I have an application with some bunch of code like this: errCode = callMainSystem();
I have the following code in my application to load some data from my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.