我有一个基于我在下面使用SQL创建的数据库的多c#报表。我正在使用以下代码尝试设置数据源,并尝试了许多不同的变体,但无法从我的数据库中获取信息,以便在报告中正确显示。任何帮助是极大的赞赏。数据集正在填充。此外,单表报告正确地填充数据只有多项报表不起作用。Crystal Reports C#
更新:报告现在使用report.Database.Tables["Invoices"].setDataSource(posDataSet.Tables["Invoices"]);
显示来自一个表的数据但是,在生成详细信息行的表上使用相同的逻辑不会显示任何数据。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
namespace SureSalePos
{
public partial class Reporter : Form
{
private PosDatabaseDataSet posDataSet;
public Reporter(PosDatabaseDataSet dataToReportOn)
{
InitializeComponent();
posDataSet = dataToReportOn;
//InvoiceReport ir = new InvoiceReport();
// this.reportViewer.LocalReport.ReportPath = ir.FileName;
}
private void Reporter_Load(object sender, EventArgs e)
{
ConnectionInfo myConnectionInfo = new ConnectionInfo();
myConnectionInfo.ServerName = "";// "PosDatabaseDataSet";
myConnectionInfo.DatabaseName = "";//"PosDatabase.mdf";
myConnectionInfo.UserID = string.Empty;
myConnectionInfo.Password = string.Empty;
setDBLOGONforREPORT(myConnectionInfo);
//this.reportViewer.RefreshReport();
}
private void setDBLOGONforREPORT(ConnectionInfo myconnectioninfo)
{
InvoiceReport report = new InvoiceReport();
report.DataSourceConnections.Clear();
// For each table set the source from your dataset
report.Database.Tables["Invoices"].SetDataSource(posDataSet.Tables["Invoices"]);
report.Database.Tables["InvoiceItems"].SetDataSource(posDataSet.Tables["InvoiceItems"]);
//report.Database.Tables["People"].SetDataSource(posDataSet.Tables["People"]);
report.Database.Tables["Preferences"].SetDataSource(posDataSet.Tables["Preferences"]);
//report.Database.Tables["Skus"].SetDataSource(posDataSet.Tables["Skus"]);
crystalReportViewer1.ReportSource = report;
crystalReportViewer1.RefreshReport();
}
private void crystalReportViewer1_Load(object sender, EventArgs e)
{
}
}
}
编辑:更新上述9月22日
你会得到数据集中的数据还是不是? –
是的数据集不会正确填充数据 – Brandon
有没有人有任何建议呢? – Brandon