我有访问数据库,我有付款表。我在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());
}
答案 0 :(得分:0)
如果使用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;
}