Skip to Content
author's profile photo Former Member
Former Member

Report tries to connect to wrong database

Hello,

We're currently developing an ASP.NET C# Web Application and integrate some Crystal Reports using the CrystalReportViewer control. Our environment looks like this:

<h1>Dev Environment:</h1>

One machine using

- Windows Server 2003

- .NET Framework 3.5 SP1

- IIS 6

- SQL Server 2008 Developer Edition, Default instance

- Crystal Reports 2008 (no service packs applied so far)

<h1>Production Environment:</h1>

One machine using

- Windows Server 2008

- .NET Framework 3.5 SP1

- IIS 7

- SQL Server 2008 Express Edition, Named instance

I've designed the report on the Dev Environment. For this I created a new database connection inside the report to the Dev Database. We use OLE DB for SQL Server to connect to the database using sql authentication. We pass the login credentials in code. The report uses two sql server views and one sql table to display its data. The report is configured to not store data inside.

To pass the login credentials, we use the same code as recommended in your code samples on https://www.sdn.sap.com/irj/boc/samples:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using CrystalDecisions.Shared;

namespace Ispin.Irma.Helpman
{
    public partial class ShowReport : System.Web.UI.Page
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            ConfigureCrystalReports();
        }

        private void ConfigureCrystalReports()
        {
            string ReportPath = Server.MapPath("ReportCallTimeUsage.rpt");    

            ConnectionInfo connectionInfo = new ConnectionInfo();

            connectionInfo.ServerName = "ANANKE\\SQLEXPRESS";
            connectionInfo.DatabaseName = "Irma";
            connectionInfo.UserID = "<username goes here>";
            connectionInfo.Password = "<password goes here>";
            CrystalReportViewer1.ReportSource = ReportPath;
            SetDBLogonForReport(connectionInfo);
        }

        private void SetDBLogonForReport(ConnectionInfo connectionInfo)
        {
            TableLogOnInfos tableLogOnInfos = CrystalReportViewer1.LogOnInfo;
            foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
            {
                tableLogOnInfo.ConnectionInfo = connectionInfo;
            }
        }
    }
}

<h1>Problem:</h1>

When deploying the application and reports to the production environemt, the reports come up with a login window, forcing me to enter login credentials to the dev database. At this point I can only change the username and passwort fields, but not the server or the database. So, I'm unable to enter the correct login data to connect to the production system since this is on another machine.

<h1>What I already did:</h1>

- Install Crystal Reports 2008 runtime on production webserver (this helped, but the login problem still arises). I got the runtime from https://websmp230.sap-ag.de/sap(bD1kZSZjPTAwMQ==)/bc/bsp/spn/bobj_download/main.htm, I've choosen the "Crystal Reports 2008 - Redistributable Installation" file, published on 10.09.2008.

- Install Crystal Reports 2008 Trial Edition on production server (I could start the report sucessfully out of the designer using the login credentials for the productive database server).

It seems that the code for passing the credentials at runtime is not effective. It looks as if the report is saving login credentials inside the rpt file. but why? It must be possible to pass login credentials by code. Can you please provide me additional hints for getting this thing to work?

Thank you very much.

Edited by: AndreG on Aug 9, 2009 3:41 PM

Code formatting seems not to work.... sorry.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Aug 27, 2009 at 09:41 PM

    Lots of posting for this same question. Please search before posting the same question again.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.