SqlExec%

Sends the statements in the command buffer to SQL Server for execution.

Syntax

SqlExec% ( sqlconn% )

where

sqlconn%
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.

Returns

SUCCEED (1) or FAIL (0). Any of the following conditions causes SqlExec% to return FAIL:

Remarks

SqlExec% sends Transact-SQL statements stored in the command buffer to SQL Server. You can add statements to the command buffer by calling SqlCmd%. If one or more of the statements sent to SQL Server cannot be executed, none of the statements is processed.

Once SqlExec% returns SUCCEED, you must call SqlResults% to process the results.

SqlExec% is equivalent to SqlSend% followed by SqlOk%.

Example

The following code fragment shows a typical sequence of calls:

'Put the statement into the command buffer.
Result% = SqlCmd%(Sqlconn%, "SELECT data FROM table")

'Send the statement to SQL Server and start execution.
Result% = SqlExec%(Sqlconn%)

'Process the statement results.
Result% = SqlResults%(Sqlconn%)

'Retrieve and process the data in each row.
DO UNTIL SqlNextRow%(Sqlconn%) = NOMOREROWS

    'Code to print or process row of data.

LOOP

See Also

SqlCmd%, SqlNextRow%, SqlOk%, SqlResults%, SqlSend%, SqlSetTime%