Gets the type, length, name, and server datatype of a specific column in the current set of results.
SqlGetColumnInfo% ( sqlconn%, columndata, column% )
where
SUCCEED (1) or FAIL (0). The column type, length, name, and SQL Server datatype are returned by the columndata parameter.
SqlGetColumnInfo% performs the actions of several other DB-Library for Visual Basic functions and puts the results of those functions in the corresponding elements of the columndata parameter. SqlGetColumnInfo% is the equivalent of calling SqlColType%, SqlColLen%, and SqlColName$. To access the information about an element returned by columndata, you must use the point (.) notation:
columndata.elementname
For example, the following statement gets the column name returned by columndata:
ColumnName$ = columndata.colname$
You can call SqlGetColumnInfo% any time after you call SqlResults%.
'Put command into the command buffer. cmd$ = "SELECT title_id, price, advance FROM titles" Result% = SqlCmd%(SqlConn%, cmd$) 'Send the command to SQL Server and start execution. Result% = SqlExec%(SqlConn%) Result% = SqlResults%(SqlConn) 'Get the column name, the datatype used by the server, and the maximum 'possible length of the data in the column and print the results. IF Result% = SUCCEED THEN DO UNTIL Result% = NOMOREROWS Result% = SqlNextRow%(SqlColunn%) IF Result% = NOMOREROWS THEN Exit DO ELSE GetColumnInfo% = SqlGetColumnInfo%(SqlConn%, Dim ColDetail as ColumnData, Column%) IF GetColumnInfo% = SUCCEED THEN ColumnName$ = ColDetail.ColName$ ColDatatype$ = ColDetail.ColSqlType$ ColLength& = ColDetail.Collen& PRINT "Column name is " ColumnName$ PRINT "Datatype of column is " ColDatatype$ PRINT "Maximum possible length of data = " ColLength& PRINT END IF END IF LOOP
SqlColLen%, SqlColType%, SqlColName$, SqlGetAltColInfo%