Export (0) Print
Expand All

Data Access Overview (Managed Device Projects)

The Visual Studio integrated development environment (IDE) for developing device projects that work with data resembles the environment for developing desktop data applications. Managed data applications for devices rely on ADO.NET namespaces supported by the .NET Compact Framework. This combination lends itself to applications where the data store on the device is typically disconnected from data on a server and is only periodically synchronized.

This topic covers the following information:

  • Types of external data

  • Connecting to data

  • Accessing data in device applications.

Since the .NET Compact Framework implements ADO.NET, device applications can connect to numerous external data sources, such as the following:

  • Databases

    • SQL Server

    • SQL Server Compact 3.5

    • SQL Server Mobile Edition

  • Web services

  • XML files

  • Business objects

For more information, see Data Access and XML Support in the .NET Compact Framework.

Device developers often use SQL Server Compact 3.5 in device applications because most mobile devices cannot maintain a reliable network connection.

With SQL Server Compact 3.5, the device application continues to function when the device is disconnected because the data is store locally on the device as a database file (.sdf). When a network connection is found, the application can synchronize with the remote SQL Server database. For more information, see Using SQL Server Compact 3.5 Databases (Devices).

In order to access external data in your device application, you must create a data source in your device project. A data source is an object in your device application that represents the external data. The data source knows how to connect to, retrieve, and update external data in a database or a Web service. The data source also exposes the data to device applications through DataSet or System.Data.SqlServerCe.SqlCeResultSet objects. For more information, see Data Sources Overview and Connecting to Data in Visual Studio Overview.

Visual Studio provides tools to automatically generate data sources and manage connection strings. For more information, see:

How to: Add a Business Object as a Data Source (Devices)

How to: Add a SQL Server Database as a Data Source (Devices)

How to: Add a Web Service as a Data Source (Devices)

How to: Change the Run-Time Connection String (Devices)

How to: Change the Design-Time Connection String (Devices)

If the data source exposes data through a DataSet object, your device application can directly access data in a DataSet by accessing the DataTable and DataRow objects in the DataSet . Also, you can bind user interface (UI) controls such as DataGrid, ListBox, and ComboBox to data in a DataSet .

Some data sources do not expose data through DataSet objects. A data source that connects to a SQL Server Compact 3.5 database can expose a System.Data.SqlServerCe.SqlCeResultSet instead. For more information, see Using SQL Server Compact 3.5 Databases (Devices).

NoteNote:

By default, SQL Server Compact 3.5 documentation is not installed locally. To download SQL Server Compact 3.5 Books Online, go to the SQL Server Compact 3.5 Books Online Download Center.

Community Additions

ADD
Show:
© 2015 Microsoft