Resultsets versus Datasets
This documentation is archived and is not being maintained.

Resultsets versus Datasets (Devices)

The Visual Studio Data Source Configuration Wizard can generate data source code in device projects that are based on either DataSet or System.Data.SqlServerCe.SqlCeResultSet. The generated code represents a data source in your device project that can be bound to user interface controls and exchange data with a SQL Server Compact 3.5 database. However, SqlCeResultSet-based code runs faster, uses less memory, and is less verbose than DataSet-based code. This is because SqlCeResultSet uses a pointer to work directly with the database whereas DataSet stores a copy of the data from the database in the device application. This topic describes both SqlCeResultSet and DataSet-based data sources.


By default, Visual Studio generates DataSet-based code when you use the Data Source Wizard to create a new data source. To generate either or both of these classes, see How to: Generate SqlCeResultSet Code (Devices).

The following diagram illustrates the architectural difference between SqlCeResultSets and DataSets.

The differences between SqlCeResultSet and DataSet

When the Data Source Configuration Wizard generates a SqlCeResultSet-based data source, it creates a class that inherits from SqlCeResultSet. Unlike the DataSet-based data sources, SqlCeResultSet-based data sources do not store data. Instead, the SqlCeResultSet maintains a pointer to the database and reads and updates data in the database without using a TableAdapter. Direct access to the database is possible because SqlCeResultSet is part of the .NET Compact Framework Data Provider for SQL Server Compact 3.5 (SQL Server Mobile in earlier versions). For more information, see Generating Typed ResultSets.

Overall, SqlCeResultSet-based data sources require less memory, have better performance, but have fewer features than DataSet-based data sources.

When the Data Source Configuration Wizard generates a DataSet-based data source, it creates classes to represent the data and a TableAdapter class to exchange data between the application and the database. The classes that represent the data inherit from DataSet, Microsoft.Office.Interop.Excel.DataTable, and DataRow, and the classes store the data from the database. The Data Source Wizard generates the following to mirror the relational structure and constraints of the database:

  • A class derived from DataSet that contains a Datatable for each table selected in the Add Data Source Wizard. For more information, see Typed DataSets (ADO.NET).

  • Each class derived from DataTable also contains a set of DataColumn objects that mirror the columns in the database.

  • A class derived from DataRow for each table.

  • Relational constraints from the database such as non-null, unique, primary keys, and foreign keys.

  • A TableAdapter class to exchange data between the database and the data objects in the device application. The TableAdapter class contains methods to read data from a database and write changed data back to the database. For more information, see TableAdapter Overview.

The classes earlier in this topic are compatible with ADO.NET architecture. Thus, the data access model resembles ADO.NET data that uses the .NET Framework on the desktop. For more information, see Accessing Data (Visual Studio) and Data Access and XML Support in the .NET Compact Framework.

Overall, DataSet-based data sources have more features, but they also require more memory and processor resources than SqlCeResultSet-based data sources.

© 2016 Microsoft