Link to home
Start Free TrialLog in
Avatar of dyarosh
dyarosh

asked on

Database Logon Failed Error in Crystal Reports

I have a Crystal Report that uses a Class as the data source for the report.  When I try and run the report I am getting a Database Logon Failed error.  How do I get rid of this error since I'm not using a database?
Avatar of Mike McCracken
Mike McCracken

What version of Crystal?

How was the report built?

mlmcc
Avatar of dyarosh

ASKER

Crystal v11

I have a class that I created to interface with my database, CVLData.  I load the data into the class on page load.  When I created the report, I chose the CVLData object as my report source and use the variables in the class on the report.

Here is a snippet of how the class is defined:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace CVL
{
    public class CVLData
    {
        // Define fields to hold CVL data from the form
        // CVLID - unique Cover Verification Letter ID
        private Int32 _CVLID;
        public Int32 CVLID
        {
            get
            {
                return this._CVLID;
            }
            set
            {
                this._CVLID = value;
            }
        }

        // CVL_Policy
        // PolicyNumber
        private string _PolicyNumber;
        public string PolicyNumber
        {
            get
            {
                return this._PolicyNumber;
            }
            set
            {
                this._PolicyNumber = value;
            }
        }

        // EffectiveDate
        private string _EffectiveDate;
        public string EffectiveDate
        {
            get
            {
                return this._EffectiveDate;
            }
            set
            {
                this._EffectiveDate = value;
            }
        }

        // StateName
        private string _StateName;
        public string StateName
        {
            get
            {
                return this._StateName;
            }
            set
            {
                this._StateName = value;
            }
        }

        // FirstName
        private string _FirstName;
        public string FirstName
        {
            get
            {
                return this._FirstName;
            }
            set
            {
                this._FirstName = value;
            }
        }

        // LastName
        private string _LastName;
        public string LastName
        {
            get
            {
                return this._LastName;
            }
            set
            {
                this._LastName = value;
            }
        }
...
}

So FirstName, LastName, etc. are used on the report.
When you instatiate the class does it need to log into the database?

If so what does it use as credentials?

mlmcc
Avatar of dyarosh

ASKER

I retrieve data from a SQL Server database and use credentials for accessing that data.  The particular report that I am trying to generate is a letter and it is created using data from only one record in the database.
If you don't use the report but just display the data from the class is there a login required?

mlmcc
Avatar of dyarosh

ASKER

I set the EnableDatabaseLogonPrompt to true and I get the following:
User generated image
Any ideas?
Avatar of dyarosh

ASKER

Here is how I setup the report in code behind:

        protected void VerifyCVL_Click(object sender, EventArgs e)
        {
            ReportDocument cryRpt = new ReportDocument();
            cryRpt.Load(Server.MapPath("CVLRpt.rpt"));
            CrystalReportViewer1.ReportSource = cryRpt;
            CrystalReportViewer1.RefreshReport();
        }

If I create a report with no data, just text, the report displays fine.  I don't have to change anything in my code behind except the report name.
How did you build CVLRpt.rpt?

Are you using a stand-alone version of Crystal or did you build the repor tin VS and save it?

At that point is the class instantiated and open?

mlmcc
Avatar of dyarosh

ASKER

I built the report in VS and saved it.  During the design, the class is not instantiated since the program is not running.
Can you create an object of the class then show the data?
Does that require a login?
I suspect it will.

mlmcc
Avatar of dyarosh

ASKER

What do you mean create an object of the class then show the data?

I declare the class this way:

        // Create an object of the CVLData class
        static CVLData cvldata = new CVLData();

When I debug, I am able to view the data in the class in the Immediate Window as follows:
cvldata.CVLID  

This displays the valid CVLID.  I can successfully query other fields in the class.  It does not require a logon.
I don't know then.  Crystal is apparently trying to log into a database for something.  I don't have a VS.Net environment to build a class and report in to help.

mlmcc
ASKER CERTIFIED SOLUTION
Avatar of dyarosh
dyarosh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dyarosh

ASKER

Found a link that addressed my problem.