C# Crystal Report Warnings The report you requested requires further information

5.8k views Asked by At

I use C#.NET (WebApp) VS 2008 SP1

I want click next page from crystal report v.10.5.3700 (Framework 3.5) but it's show input data to next page

The report you requested requires further information Server name:
Database name:
User name:
Password:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;
using System.Diagnostics;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Transactions;
using System.Drawing;
using System.Globalization;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;

namespace testReport
{
    public partial class _cldClass : System.Web.UI.Page
    {
        SqlConnection objConn = new SqlConnection();
        SqlCommand objCmd = new SqlCommand();
        SqlDataAdapter dtAdapter = new SqlDataAdapter();
        SqlConnection Conn;

        DataSet ds = new DataSet();
        DataTable dt = null;
        string strConnString = WebConfigurationManager.ConnectionStrings["connDB"].ConnectionString;
        string strSQL = null;


        public string userDB
        {
            get { return WebConfigurationManager.AppSettings["userDB"]; }
        }
        public string pwdDB
        {
            get { return WebConfigurationManager.AppSettings["pwdDB"]; }
        }
        public string srvDB
        {
            get { return WebConfigurationManager.AppSettings["srvDB"]; }
        }
        public string dbName
        {
            get { return WebConfigurationManager.AppSettings["dbName"]; }
        }

        //protected void Page_Load(object sender, EventArgs e)
        //{
        //}

        protected void Page_Init(object sender, EventArgs e)
        {
            TextBox2.Text = DateTime.Now.ToString("yyyy-MM-dd", new CultureInfo("en-US"));
            Conn = new SqlConnection(strConnString);
            Conn.Open();

            if (Conn.State == ConnectionState.Open)
            {
                this.Label1.Text = "Connected";
            }
            else
            {
                this.Label1.Text = "Connect Failed";
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            strSQL = "SELECT * FROM fTime WHERE fDate='" + TextBox2.Text + "'";

            objConn.ConnectionString = strConnString;
            var _with1 = objCmd;
            _with1.Connection = objConn;
            _with1.CommandText = strSQL;
            _with1.CommandType = CommandType.Text;
            dtAdapter.SelectCommand = objCmd;

            dtAdapter.Fill(ds, "cReport");
            dt = ds.Tables[0];

            dtAdapter = null;
            objConn.Close();
            objConn = null;

            ReportDocument rpt = new ReportDocument();
            rpt.Load(Server.MapPath("Report\\CrystalReport.rpt"));
            rpt.SetDataSource(dt);
            rpt.SetDatabaseLogon(userDB, pwdDB, srvDB, dbName);
            CrystalReportViewer1.ReportSource = rpt;
            CrystalReportViewer1.RefreshReport();       
        }
    }
}

Thanks for your time :)

2

There are 2 answers

0
Daniel On

Normally you need to enter these informations when you created the report document directly from a database, that means when you used the report wizard and selected a table from the database. The report document itself contains the connection information to that data source but don't saves the logon information.

To overcome this you may create a typed dataset first from your database table you like to use in the report. Then create a report document and use the wizard to set the dataset (not the database table directly) as data source for your report. In your code you may then fill the dataset and just pass it to the report.

1
Andrew On

I ran into this today, and the reason I got the error was because I didn't have the correct provider installed on my server.

What I did was this:

 CrystalReportViewer1.EnableDatabaseLogonPrompt = false;

That gave me a new error: Logon failed. Details: ADO Error Code: 0x Source: ADODB.Connection Description: Provider cannot be found. It may not be properly installed

After that, I checked the OLE DB provider in the report. Installing the SQL Native Client tools fixed the problem.