У меня есть отчет в VS2008 с таблицей и 10 текстовыми полями. Я успешно привязал значения к таблице из таблицы БД. Но как связать текстовые поля с другой таблицей БД в том же отчете? Как одновременно связать несколько наборов данных в одном и том же коде? что, если я использую более одного запроса для получения данных для одного отчета? Ниже приведен пример кода, который я сделал, чтобы привязать данные к таблице в .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();`