Executing the Commands using TSQLDataSet
Go Up to Using dbExpress
You can use a unidirectional dataset even if the query or stored procedure it represents does not return any records. Such commands include statements that use Data Definition Language (DDL) or Data Manipulation Language (DML) statements other than SELECT statements. The language used in commands is server-specific, but usually compliant with the SQL-92 standard for the SQL language. The SQL command you execute must be acceptable to the server you are using. Unidirectional datasets neither evaluate the SQL nor execute it, but pass the command to the server for execution.
To execute commands
- Choose File > New > Other. The New Items dialog appears.
- In the New Items dialog, select Delphi Projects and double-click VCL Forms Application. The Windows Designer displays.
- From the dbExpress category of the Tool Palette, drag a TSQLDataSet component to the form.
- Specify the command to execute.
- Execute the command.
- Create and modify server metadata.
To specify the command to execute
- Set the CommandType and CommandText properties in the Object Inspector to specify the command for a TSQLDataSet.
- Set the SQL property in the Object Inspector to specify the SQL statement to pass to the server for a TSQLQuery .
- Set the StoredProcName property in the Object Inspector to specify the name of the stored procedure to execute for a TSQLStoredProc .
To execute the command
- If the dataset is an instance of a TSQLDataSet or a TSQLQuery, call the ExecSQL method.
- If the dataset is an instance of a TSQLStoredProc, call the ExecProc method.
Tip: If you are executing the query or stored procedure multiple times, it is a good idea to set the Prepared property to True.
To create and modify server metadata
- To create tables in a database, use the CREATE TABLE statement.
- To create new indexes for those tables, use the CREATE INDEX statement.
- To add various metadata objects, use CREATE DOMAIN, CREATE VIEW, CREATE SCHEMA, and CREATE PROCEDURE statements.
- To delete any of the above metadata objects, use DROP TABLE, DROP VIEW, DROP DOMAIN, DROP SCHEMA, and DROP PROCEDURE.
- To change the structure of a table, use the ALTER TABLE statement.