SqlResults%

Sets up the next statement in the command buffer for processing.

Syntax

SqlResults% ( sqlconn% ) ( )

where

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

Returns

SUCCEED (1), FAIL (0), NOMORERESULTS (2), or NOMORERPCRESULTS (3). The most common reason for failing is an invalid SQL Server connection. NOMORERPCRESULTS is returned when stored procedure return information is available from one stored procedure in a batch of multiple stored procedures. NOMORERESULTS is returned if there are no more results to be processed.

Note This function is one of the four that do not return control to the application until the server sends the required response. The application can be blocked for a considerable time if the server is waiting for a lock or processing a large sort. If this is unacceptable, always call SqlDataReady% before SqlResults% and set the DB-Library timeout to regain control periodically.

Remarks

SqlResults% is called after SqlExec% or SqlOk% returns SUCCEED. SqlResults% always returns SUCCEED or NOMORERESULTS on the first call if SqlExec% or SqlOk% has returned SUCCEED, unless a network error or out-of-memory error has occurred. Once SqlResults% returns SUCCEED, you typically process any result rows using SqlNextRow% unless a network error or out-of-memory error has occurred.

SqlResults% must be called for each statement in the command buffer, whether or not the statement returns any rows. If the number of statements in the command buffer is unknown, you can call SqlResults% until it returns NOMORERESULTS. You must also call SqlResults% once for each stored procedure in the command buffer. However, if the stored procedure contains more than one Transact-SQL SELECT statement, SqlResults% must be called once for each statement. The easiest way to do this is to continue to call SqlResults% until it returns NOMORERESULTS.

You must call SqlResults% until it returns NOMORERESULTS or until any continued use of the connection causes the DB-Library error 10038 "Results Pending."

Example

'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%)
DO UNTIL Result% = NOMORERESULTS    '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
LOOP

See Also

SqlCancel%, SqlCanQuery%, SqlExec%, SqlNextRow%, SqlOk%, SqlOpen%