Executing Data Definition Language (DDL) Commands

The majority of commands that are invoked against a database are data retrieval and manipulation commands. Occasionally, however, one must do something dynamically to the structure of the database itself. This might be adding or modifying a table, stored procedure, or other such operations.

There are no dedicated .NET classes that perform these operations explicitly. However, you can still execute DDL commands using the IDbCommand.ExecuteNonQuery() method. Listing 19.3 illustrates this technique.

Listing 19.3. Executing DDL Commands
1: program ddlquery; 2: 3: {$APPTYPE CONSOLE} 4: 5: {%DotNetAssemblyCompiler 'c:\windows\microsoft.net\framework\v1.1.4322\System.Data.dll'} 6: 7: uses 8: SysUtils, ...

Get Delphi for .NET Developer’s Guide 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.