Generating SqlCommand Objects with the SqlCeCommandBuilder

Looking back at Listing 7.11, you can see that several lines of code are required to set up the update, insert, and delete commands of the SqlCeDataAdapter. The SqlCeCommandBuilder can do this work for you, but the SqlCeDataAdapter must be handling a single source table.

First, you need to initialize the SqlCeDataAdapter and its SelectCommand property. You then create SqlCeCommandBuilder that passes the SqlCeDataAdapter as a parameter to the SqlCeCommandBuilder constructor. The SqlCeCommandBuilder will then create a command for SqlCeDataAdapter's UpdateCommand, InsertCommand, and DeleteCommand properties. Listing 7.14 demonstrates how to use the SqlCeCommandBuilder to build a SqlCeDataAdapter ...

Get Microsoft® .NET Compact Framework Kick Start 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.