Home > Language Reference > Database Functions > DbGetFieldNumeric

DbGetFieldNumeric

The DbGetFieldNumeric function retrieves the value of a numeric field (integer) within the current record for the recordset in use.

Usage

Used to retrieve the content of an integer field.

Syntax

Ret=DbGetFieldNumeric(<field_name>,<value>)

Parameters

<field_name>, string, name of the field to retrieve.
 
<value>, numeric variable which contains the value of the field.

Return value

ret, optional numeric return value. If the function successfully retrieves the content of the field, the return value is 0. If the function fails, the return value is a nonzero value (see Error Codes for Database Functions).

See also

DbBof
DbClose
DbConnect
DbDisconnect
DbEof
DbExecute
DbGetFieldString
DbMove
DbMoveFirst
DbMoveLast
DbMoveNext
DbMovePrev
DbRecordCount
DbSelect

Example

'The example uses a data source name called DBTest which contains those records in a table called DATA:
' a,1, 1.23, 02/01/2011
' b,2, 2.34, 03/02/2012
' c,3, 3.45, 04/12/2009
DbConnect("DSN=DBTest") ' connection to ODBC database called DBTest
DbSelect("SELECT * FROM DATA",DYNASET) ' select all records in table DATA.
#Ignoreerrors=0 ' Ignore execution errors, instead test the return code of the called function.
While not DbEof() ' while there are still records to read.
ret=DbGetFieldNumeric("Champ2",num) ' num contains the numeric value of field called Champ2
If ret<>0 then ' if an error occurs during retrieval
 msgbox("error")
 Stop
endif
msgbox(str$(num)) ' display the value of the field
DbMovenext() ' move to next record
Wend