Click here to Skip to main content
15,909,193 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
DataSet dtUser = new DataSet();
            SqlCommand cmd = dcon.CreateCommand("Get_AllUser", true);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dtUser);
            if (dtUser.Tables[0].Rows.Count > 0)
            {
                dtUser.Tables[0].Columns.Add("S_No");
                for (int i = 0; i <= dtUser.Tables[0].Rows.Count - 1; i++)
                {
                    dtUser.Tables[0].Rows[i]["S_No"] = i + 1;
                }
            }
            ReportDocument report = new ReportDocument();
            dsUserEntry ds = new dsUserEntry();
            ds.Tables[0].Merge(dtUser.Tables[0]);
            
            report.Load(Server.MapPath("RepotUserEntry.rpt"));
            report.SetDataSource(ds);
            CrystalReportViewer1.ReportSource = report;
        }
        catch (Exception ex) { throw ex; }
        finally { dcon.CloseConnection(); }


Above code using for crystal report.
its display the report but when i clicked the print button of crystal report
following error occured:
The report you requested requires further information.
dsUserEntry
ServerName:dsUserEntry
Database name:
user name:
Password:

how to solve this problem
Posted
Updated 13-Feb-12 20:16pm
v2

You need to add the login credentials of Database as below

C#
protected void Page_Load(object sender, EventArgs e)
    {
        ReportDocument crystalReport = new ReportDocument();
        crystalReport.Load(Server.MapPath("CrystalReport.rpt"));
        crystalReport.SetDatabaseLogon
            ("amit", "password", @"AMIT\SQLEXPRESS", "TestDB");
        CrystalReportViewer1.ReportSource = crystalReport;
    }
 
Share this answer
 
Comments
aftab5124 17-Feb-12 1:53am    
Invalid report file path error occur
Add The TableLogOnInfo to your report.
 
Share this answer
 
You have to set logon information at run time.
C# Crystal Reports Dynamic Logon parameters [^]
 
Share this answer
 
previous code:
if(!Ispostback)
{
DataSet dtUser = new DataSet();
SqlCommand cmd = dcon.CreateCommand("Get_AllUser", true);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dtUser);
if (dtUser.Tables[0].Rows.Count > 0)
{
dtUser.Tables[0].Columns.Add("S_No");
for (int i = 0; i <= dtUser.Tables[0].Rows.Count - 1; i++)
{
dtUser.Tables[0].Rows[i]["S_No"] = i + 1;
}
}
ReportDocument report = new ReportDocument();
dsUserEntry ds = new dsUserEntry();
ds.Tables[0].Merge(dtUser.Tables[0]);

report.Load(Server.MapPath("RepotUserEntry.rpt"));
report.SetDataSource(ds);
CrystalReportViewer1.ReportSource = report;
}
catch (Exception ex) { throw ex; }
finally { dcon.CloseConnection(); }
}

just remove if() statement and problem solved.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900