Tuhin Paul
What is the purpose of the above code?
  1. string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\path\\to\\your\\database.accdb";
  2. string query = "SELECT * FROM Customers";
  3. OleDbConnection connection = new OleDbConnection(connectionString);
  4. OleDbDataAdapter adapter = new OleDbDataAdapter(query, connection);
  5. DataSet dataSet = new DataSet();
  6. adapter.Fill(dataSet, "Customers");
  7. ReportDataSource reportDataSource = new ReportDataSource("Customers", dataSet.Tables[0]);
  8. reportViewer1.LocalReport.DataSources.Clear();
  9. reportViewer1.LocalReport.DataSources.Add(reportDataSource);
  10. reportViewer1.RefreshReport();

What is the purpose of the above code?
A) To retrieve data from a Microsoft Access database and display it in a report viewer.
B) To retrieve data from a MySQL database and display it in a report viewer.
C) To retrieve data from a SQL Server database and display it in a report viewer.
D) To retrieve data from a PostgreSQL database and display it in a report viewer.

By Tuhin Paul in .NET on Apr 15 2023
  • Tuhin Paul
    May, 2023 7

    A) To retrieve data from a Microsoft Access database and display it in a report viewer.

    The code is creating a connection to a Microsoft Access database using an OleDbConnection object and a connection string. It is then using an OleDbDataAdapter to execute a SELECT query on the Customers table in the database and fill a DataSet object with the results. It is creating a ReportDataSource object using the DataSet and setting it as the data source for a report viewer control. This will display the data from the Customers table in the report viewer.

    • 1
  • Amit Nagar
    Jun, 2023 27

    A) To retrieve data from a Microsoft Access database and display it in a report viewer.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS