Keyword Index

Object: SPDatabase

This object represents a database created by Microsoft Access or a similar database product and allows access to records within the database. New SPDatabase objects are created using the SPDatabase top-level method.

  • addRecord - Adds a new record and sets the field values. Any number of name/value pairs can be specified.
  • eof - Indicates if the record set is positioned at end-of-file
  • findRecords - Finds records in the current table based on field name/value pairs. Any number of name/value pairs can be specified.
  • getFieldValue - Gets the value of a single field in the current record
  • moveFirst - Moves to the first record in the set of currently selected records.
  • moveNext - Moves to the next record in the set of currently selected records.
  • moveNextPrev - Moves to the previous record in the set of currently selected records.
  • openSelect - Opens a database table using a SQL SELECT statement provided as an argument. This allows section of records from the database using any facilities of the SELECT statement. To select records using simple field value comparisons, using the findRecords method is easier.
  • openTable - Opens a database table and selects all records in the table.
  • recordCount - Returns the number of currently selected records
  • setFieldValue - Sets one or more field values in the current record. This method takes any number of name/value pairs as arguments
  • Method: addRecord

    Adds a new record and sets the field values. Any number of name/value pairs can be specified.

    void addRecord(name1, value1, ...);

    Parameters
    Name Expected Type Description
    name1 String The name of the field to add
    value1 String The value for this field. All values are converted to strings

    Returns:

    None

    Remarks:

    NOTE: The data type of the value must match the type of the database field, e.g. a text database field must have a string value, an integer field must have an integer value, etc.

    Method: eof

    Indicates if the record set is positioned at end-of-file

    Method: findRecords

    Finds records in the current table based on field name/value pairs. Any number of name/value pairs can be specified.

    int findRecords(name1, value1, ...);

    Parameters
    Name Expected Type Description
    name1 String The name of the field to compare
    value1 String The value for this field. All values are converted to strings

    Returns:

    Returns the number of records that were selected.

    Remarks:

    NOTE: The data type of the value must match the type of the database field, e.g. a text database field must have a string value, an integer field must have an integer value, etc.

    Method: getFieldValue

    Gets the value of a single field in the current record

    String = getFieldValue(fieldName);

    String = getFieldValue(fieldName, defaultValue);

    Parameters
    Name Expected Type Description
    fieldName String The name of the field to retrieve
    defaultValue String The value to return if the field is not found or the value is empty

    Method: moveFirst

    Moves to the first record in the set of currently selected records.

    Returns:

    Returns true if a new record is selected, false if the set was empty

    Method: moveNext

    Moves to the next record in the set of currently selected records.

    Returns:

    Returns true if a new record is selected, false if the set is now positioned at the end of the list.

    Method: moveNextPrev

    Moves to the previous record in the set of currently selected records.

    Returns:

    Returns true if a new record is selected, false if the set was empty

    Method: openSelect

    Opens a database table using a SQL SELECT statement provided as an argument. This allows section of records from the database using any facilities of the SELECT statement. To select records using simple field value comparisons, using the findRecords method is easier.

    bool openSelect(selectStr);

    Parameters
    Name Expected Type Description
    selectStr String A valid SELECT statement, including the SELECT keyword itself. This is passed directly to the database engine without any checking.

    Returns:

    Returns true if the select was accepted. This does not indicate whether any records were found or not.

    Remarks:

    After this statement, recordCount can be used to determine if any records were found, moveFirst, moveNext and movePrev to iterate through the found records, and getFieldValue can be used to extract values.

    Method: openTable

    Opens a database table and selects all records in the table.

    bool openTable(tableName);

    Parameters
    Name Expected Type Description
    tableName String The name of the database table to open

    Returns:

    Returns true if the table opened OK. This does not indicate whether any records were found or not.

    Remarks:

    This method is equivalent to using openSelect with the argument "SELECT * FROM tableName"

    Property: recordCount

    Returns the number of currently selected records

    Method: setFieldValue

    Sets one or more field values in the current record. This method takes any number of name/value pairs as arguments

    void setFieldValue(name1, value1, ...);

    Parameters
    Name Expected Type Description
    name1 String The name of the field to set
    value1 String The value for this field. All values are converted to strings

    Returns:

    None

    Remarks:

    NOTE: The data type of the value must match the type of the database field, e.g. a text database field must have a string value, an integer field must have an integer value, etc.