Microsoft® .NET Compact Framework (Core Reference)
by Andy Wigley, Stephen Wheelwright, Robert Burbidge, Rory MacLoed, Mark Sutton
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access