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):
SqlException and SqlError ...