Returns the actual length, in bytes, of the data in a column.
SqlDatLen& ( sqlconn%, column% )
where
The actual length of the data in a specified column. If the column has a null value, SqlDatLen& returns 0. If the column number is out of range, SqlDatLen& returns -1. Calling SqlDatLen& after SqlNextRow% or SqlGetRow% returns regrow.
For numeric datatypes such as smallint and float, SqlDatLen& returns the maximum printable width, not the length of the string that would be returned by SqlData$. For example, if you store the value 10,000 in a smallint column, SqlDatLen& returns 6 (the storage size of the smallint datatype). The length of the string returned by SqlData$, in this case 5, is determined by using the Visual Basic LEN function.
You obtain the maximum possible length for the data in a column by calling SqlColLen%. The data itself is returned by SqlData$.
'Put the statement into the command buffer. Result% = SqlCmd%(Sqlconn%, "SELECT name FROM sysobjects") 'Send the statement to SQL Server and start execution. Result% = SqlExec%(Sqlconn%) 'Process the statement results. Result% = SqlResults%(Sqlconn%) 'Print the data length of each row. RowNum% = 0 DO UNTIL SqlNextRow%(Sqlconn%) = NOMOREROWS RowNum% = RowNum% 1 PRINT "Row"; RowNum%;" data length is "; PRINT SqlDatLen&(Sqlconn%, 1) LOOP
Output:
Row 1 data length is 10 Row 2 data length is 10 . . . Row 103 data length is 13
SqlColLen%, SqlColName$, SqlColType%, SqlData$, SqlNumCols%