使用Asp.Net的Crystal Report
问题描述:
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(); }
上面的代码用于水晶报表.
它显示报告,但是当我单击Crystal报告的打印按钮时
发生以下错误:
您请求的报告需要更多信息.
dsUserEntry
ServerName:dsUserEntry
数据库名称:
用户名:
密码:
如何解决此问题
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
答
您需要添加Database的登录凭据,如下所示
You need to add the login credentials of Database as below
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;
}
将TableLogOnInfo添加到报表中.
Add The TableLogOnInfo to your report.
您必须在运行时设置登录信息.
C#Crystal Reports动态登录参数 [
You have to set logon information at run time.
C# Crystal Reports Dynamic Logon parameters [^]