0
我在VS2008中有一个带有一个表格和10个文本框的报告。我从DB-table中有很多绑定值,但是如何将文本框与不同的DB-表在同一报告中?如何在同一代码背后绑定多个数据集?如果我使用多个查询来获取单个报表的数据,该怎么办?我所做的示例代码如下所示 - 它将数据绑定到.rdlc中的表格。将代码隐藏的多个数据集添加到.rdlc报告
//一个表映射命名DataTable。
adapter.TableMappings.Add("View", mappingTableDataSet);
// Open the connection.
connection.Open();
Console.WriteLine("\nThe SqlConnection is open.");
SqlCommand command = new SqlCommand(queryString, connection);
command.CommandType = CommandType.Text;
// Set the SqlDataAdapter's SelectCommand.
adapter.SelectCommand = command;
command.ExecuteNonQuery();
// Fill the DataSet.
DataSet dataset = new DataSet(mappingTableDataSet);
adapter.Fill(dataset);
//Set up reportviewver and specify path
ReportViewer viewer = new ReportViewer();
viewer.ProcessingMode = ProcessingMode.Local;
viewer.LocalReport.ReportPath = reportPath;
//specify the dataset syntax = (datasetofreport.rdlc,querydataset);
viewer.LocalReport.DataSources.Add(new ReportDataSource(reportDataSource, dataset.Tables[0]));
//viewer.LocalReport.DataSources.Add(new ReportDataSource("podDataSet_Route_Summary", dataset.Tables[0]));
connection.Close();`