我有一個基於我在下面使用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