【问题标题】:C# Winforms RDLC report Static crosstab columnsC# Winforms RDLC 报告静态交叉表列
【发布时间】:2018-11-01 16:59:34
【问题描述】:

我可以访问有支付表的数据库。我正在使用 c# 中的适配器加载此表,并填充一个数据集以用作 RDLC 交叉表报告的数据源。结果符合预期。但我的问题是,在添加更多数据时,报告并没有显示未来可能出现的所有列。

我的问题是,即使没有数据,如何指定要在 RDLC 交叉表报告中显示的所有必需列?

这是我的基本代码:

string sql = "select* from [payments]";
try
{
   using (OleDbConnection conn = new OleDbConnection(myGlobals.connString))
      {
          using (OleDbDataAdapter adapter = new OleDbDataAdapter(sql, conn))
          {
             DataSet ds = new DataSet();
             adapter.Fill(ds, "regPayments");
             frmReport report = new frmReport();
             BindingSource bs = new BindingSource(ds, "regPayments");
             report.ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("dsRegPayments", bs));
             report.ReportViewer.LocalReport.ReportEmbeddedResource = "Kindergarten.Report10.rdlc";
             report.Show();
          }
      }
}
catch(Exception ex)
{
    MessageBox.Show(ex.ToString());
}

【问题讨论】:

  • 能否请您发布您所谈论内容的屏幕截图,并详细说明您所说的“报告未显示未来可能出现的所有可能列”的意思?您是在谈论有人向 Access 表添加列并让报告自动选择它们吗?
  • 我的意思是,例如,1 月、2 月和 3 月存在一些付款。但在我的交叉表中,我需要显示所有 12 个月,即使那几个月没有付款

标签: c# static report rdlc crosstab


【解决方案1】:

如果您使用的是 SQL,请更改为 SQL 数据连接,如果没有,请确保您请求架构数据。

看看MSDN,你就会知道架构并不总是提供。

// Assumes a valid connection string to an Access database.
static void CreateOleDbAdapter(string connectionString)
{
    OleDbDataAdapter adapter = new OleDbDataAdapter();
    adapter.SelectCommand =
        new OleDbCommand("SELECT * FROM Categories ORDER BY CategoryID");
    adapter.SelectCommand.Connection =
        new OleDbConnection(connectionString);
    adapter.MissingMappingAction = MissingMappingAction.Error;
    adapter.MissingSchemaAction = MissingSchemaAction.Error;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-22
    • 1970-01-01
    • 2018-09-19
    • 2018-08-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多