Home > Language Reference > Database Functions > DbGetFieldString

DbGetFieldString

The DbGetFieldString function retrieves the contents of any non-numeric field within the current record for the recordset in use.

Usage

Used to retrieve the content of a non-numeric field.

Syntax

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

Parameters

<field_name>, string, name of the field to retrieve.
 
<value>, string 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
DbGetFieldNumeric
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=DbGetFieldString("Champ4",mydate$) ' the mydate$ variable contains the value of field called Champ4
If ret<>0 then ' if an error occurs during retrieval
 msgbox("error")
 Stop
endif
msgbox(mydate$) ' display the value of the field
DbMovenext() ' move to next record
Wend