Returns a string containing data in a result column.
SqlData$ ( sqlconn%, column% )
where
A string containing the data in a result column. For the SQL Server datatypes binary, varbinary, and image, SqlData$ returns a string of binary data, with one character in the string per byte of data in the result column. For all other datatypes, SqlData$ returns a string of readable characters. When there is no such column or when the data is NULL, an empty string is returned. To make sure that the data really is NULL, always check for a return of 0 by using SqlDatLen&.
Use SqlDatLen& to get the length of the data for variable-length datatypes. For numeric datatypes, use the Visual Basic LEN function to determine the length of the string returned by SqlData$.
To convert the data from a string to a different datatype, use SqlColType% to get the datatype of the data, then use Visual Basic functions to convert to Visual Basic datatypes. Some helpful Visual Basic conversion functions are shown in the following table. For more information, see your documentation for Visual Basic.
Visual Basic function |
Description |
---|---|
CDBL | Converts a numeric expression to a double-precision value. |
CLNG | Converts a numeric expression to a long integer. |
VAL | Converts a string representation of a value to a numeric expression. |
'Put the statement into the command buffer. Result% = SqlCmd%(Sqlconn%, "SELECT id FROM sysobjects") 'Send the statement to SQL Server and start execution. Result% = SqlExec%(Sqlconn%) 'Process the statement results. Result% = SqlResults%(Sqlconn%) 'Retrieve and print the data in each row. RowNum% = 0 DO UNTIL SqlNextRow%(Sqlconn%) = NOMOREROWS RowNum% = RowNum% 1 PRINT "Row"; RowNum%;" object id is "; PRINT SqlData$(Sqlconn%, 1) LOOP
SqlColLen%, SqlColName$, SqlColType%, SqlDatLen&, SqlNumCols%