Generating SQL with a Command Builder

An excellent benefit of object-oriented systems is that you have tidy compartments in which to place additional functionality, the classes themselves. The OleDbCommandBuilder and SqlCommandBuilder classes can use the command—whether literal text or command object—used to initialize an adapter and generate additional command objects. For example, when you write a SELECT statement, the schema (the columns and data types) can be inferred or read, and knowing the schema, substitution can be employed to replace SELECT with UPDATE, INSERT, or DELETE. A benefit of .NET is that the CommandBuilder class already exists and will do the work for us. Listing 11.8 demonstrates how to generate SQL for inserting, updating, ...

Get Visual Basic® .NET Power Coding 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.