SqlNumCols%

Returns the number of columns in the current set of results.

Syntax

SqlNumCols% ( sqlconn% ) ( )

where

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

Returns

The number of columns in the current results set. If there are no columns, 0 is returned.

Example

'Put two statements into the command buffer.
cmd$ = "SELECT name, type, id FROM sysobjects"
cmd$ = cmd$  " SELECT type FROM sysobjects"
Result% = SqlCmd%(Sqlconn%, cmd$)

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

'Process the results of each statement.
DO UNTIL SqlResults%(Sqlconn%) = NOMORERESULTS
   PRINT SqlNumCols%(Sqlconn%);
   PRINT "column(s) in this result."
   DO UNTIL SqlNextRow%(Sqlconn%) = NOMOREROWS
   'Code to print or process row of data.       
   LOOP
LOOP

Output:

3 column(s) in this result.
1 column(s) in this result.

See Also

SqlColLen%, SqlColName$