Recordset.getstring — get the value of a particular field as a string


string Recordset.getstring ( index);  
mixed   index;


Returns a string representation of the value of the field named by index. index can be either an int value, in which case it is taken to be a zero based column index, or a string type in which case it is taken to be a column name. Some data sources are case sensitive when specifying column names.

If the field contains SQL NULL then an empty string "" is returned. If the column is unknown then "" is also returned and an error message is set which can be read using error().

Example 68. Recordset.getstring Example

// Get some data from a fictional recordset
Recordset rs = conn.openrs("SELECT CName, CEmail FROM TPeople WHERE CPersonID="
  + personid);
if(rs != null)
    string name = rs.getstring("CName");
    string email = rs.getstring("CEmail");

See Also

Data sources and database access in RSP is explained in the section called “Accessing Databases”