Retrieving Data

A detailed look at accessing data in a SQL Server database, with a sample application, follows. The sample application, GettingSQLDataSample, is available with this book’s sample files. The application’s code retrieves some data that is to be read-only in the application and that can be collected all in one go. The sample application includes the Transact-SQL that’s required for selecting the data, but before you try the sample, you’ll need to set up the DotNetCF database that this sample accesses. (See the Readme file included with this chapter’s sample files.)

GettingSQLDataSample uses the following System.Data.SqlClient objects (in the order that you’ll meet them):

  • SqlConnection

  • SqlCommand

  • SqlDataReader

  • SqlException and SqlError ...

Get Microsoft® .NET Compact Framework (Core Reference) now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.