SqlColName$

Returns the name of a result column.

Syntax

SqlColName$ ( sqlconn%, column% )

where

sqlconn% ( )
Is a SQL Server connection. The value of sqlconn% is returned by SqlOpen%.
column%
Is the number of the column. The first column is number 1.

Returns

A string containing the name of a result column. If the column number is out of range or if the column is the result of an expression with no name assigned, an empty string is returned.

Example

The following code fragment uses SqlColName$ to return the name, id, and type column names from the sysobjects table:

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

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

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

'Print the column names.
FOR ColumnNum% = 1 TO 3
   ColumnName$ = SqlColName$(Sqlconn%, ColumnNum%)
   PRINT "Column"; ColumnNum%; " name is "; ColumnName$
NEXT ColumnNum%

Output:

Column 1 name is name
Column 2 name is id
Column 3 name is type

See Also

SqlColLen%, SqlColType%, SqlData$, SqlDatLen&, SqlNumCols%