string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\path\\to\\your\\database.accdb";string query = "SELECT * FROM Customers";OleDbConnection connection = new OleDbConnection(connectionString);OleDbDataAdapter adapter = new OleDbDataAdapter(query, connection);DataSet dataSet = new DataSet();adapter.Fill(dataSet, "Customers");ReportDataSource reportDataSource = new ReportDataSource("Customers", dataSet.Tables[0]);reportViewer1.LocalReport.DataSources.Clear();reportViewer1.LocalReport.DataSources.Add(reportDataSource);reportViewer1.RefreshReport();
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\path\\to\\your\\database.accdb";
string query = "SELECT * FROM Customers";
OleDbConnection connection = new OleDbConnection(connectionString);
OleDbDataAdapter adapter = new OleDbDataAdapter(query, connection);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, "Customers");
ReportDataSource reportDataSource = new ReportDataSource("Customers", dataSet.Tables[0]);
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(reportDataSource);
reportViewer1.RefreshReport();
What is the purpose of the ReportDataSource class in the code?A) To establish a connection to the database.B) To retrieve data from the database.C) To create a dataset to hold the data.D) To provide data to the report viewer.
D
option D - To provide data to the report viewer should be the correct option, as the purpose of ReportDataSource is to provide a way to associate the data set with a name like ‘customers’ here that can then be used in report and provide that data to reportviewer control.