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 7062109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:33:16+00:00 2026-05-28T04:33:16+00:00

I developed a Crystal report on my local machine and I can render the

  • 0

I developed a Crystal report on my local machine and I can render the report on my local website using .ExportToHttpResponse but as soon as I move my code to the production server I get a “Database logon failed” error. I basically used a .XML dataset file as the source to develop the report locally. This was my code:

I call a method to render the report:

private void RenderCrystalReports(string rptName, string pdfReportName, DataSet dataForReport)
  {
    string reportPath = Server.MapPath(@"\App_Data\Reports\" + rptName);
    ReportDocument report = new ReportDocument();
    report.Load(reportPath, OpenReportMethod.OpenReportByTempCopy);
    SetDBLogonForReport(ref report);
    report.SetDataSource(dataForReport);
    SetDBLogonForReport(ref report);
    report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, true, pdfReportName);
  }

and to get the dataset I have:

private DataSet GetReportData(DateTime from, DateTime to, int userID, bool totalsOnly)
  {
    DataTable Job = _reportRepository.GetAccountHistoryJob(from, to, userID, totalsOnly);
    Job.TableName = "Accounts";
    DataSet ds = new DataSet("AccountsDS");
    ds.Tables.AddRange(new DataTable[] { Job });
    return ds;
  }

and as far as I am concerned the method below is what is supposed to help me to connect to the remote SQL server:

private void SetDBLogonForReport(ref ReportDocument reportDocument)
  {
    SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(ConfigurationManager.ConnectionStrings["MyConnectionString"].ToString());
    ConnectionInfo connectionInfo = new ConnectionInfo();
    connectionInfo.DatabaseName = builder.InitialCatalog;
    connectionInfo.UserID = builder.UserID;
    connectionInfo.Password = builder.Password;
    connectionInfo.ServerName = builder.DataSource;

    Tables tables = reportDocument.Database.Tables;
    foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
    {
      TableLogOnInfo tableLogonInfo = table.LogOnInfo;
      tableLogonInfo.ConnectionInfo = connectionInfo;
      table.ApplyLogOnInfo(tableLogonInfo);
    }
  }

Why does this not work? I just figured out that even locally the .xml dataset is used so how do I use the sql dataset that I get?

  • 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-05-28T04:33:17+00:00Added an answer on May 28, 2026 at 4:33 am

    This is the code that worked for me:

    public ActionResult TestReport() {
      RenderCrystalReports("demoRPT.rpt", "Some Report", GetReportDs());
      return View();
    }
    
    
    #region Private methods
    private void RenderCrystalReports(string rptName, string pdfReportName, DataSet dataForReport)
    {
      string reportPath = Server.MapPath(@"\Reports\" + rptName);
      ReportDocument report = new ReportDocument();
      report.Load(reportPath, OpenReportMethod.OpenReportByTempCopy);
    
      DataTable jobTable = GetReportTable();
      report.Database.Tables[0].SetDataSource(jobTable);
    
      report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, System.Web.HttpContext.Current.Response, true, pdfReportName);
    
    }
    
    private DataTable GetReportTable()
    {
      DataTable Job = GetReportData();
      Job.TableName = "Accounts";
      return Job;
    }
    
    private DataSet GetReportDs()
    {
      DataTable Job = GetReportData();
      Job.TableName = "Accounts";
      DataSet ds = new DataSet("AccountsDS");
      ds.Tables.AddRange(new DataTable[] { Job });
      return ds;
    }
    
    private DataTable GetReportData()
    {
      DataTable table = new DataTable();
      table.Columns.Add("Date", typeof(DateTime));
      table.Rows.Add(DateTime.Now);
      return table;
    }
    #endregion
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a report in Crystal Report 2008 but When I try to
WE developed system integrated with crystal Reports, with Crystal Report viewer on page. but
I have a report developed with Crystal '08 and it is published on CMC.
I have some reports developed using Crystal Reports 12 and I want to version
I have a legacy app that can display crystal reports to the user, using
I'm researching using Microsoft Reporting Services as a replacement for Crystal Reports. In production,
We have developed a set of crystal reports (not my idea) that are to
We developed a website for a client and he has purchased the .com, .net,
I developed a Word 2003 report generation application that extracts data from a database.
I have a Crystal 2008 report that will be deployed to an InfoView server.

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.