DatabaseUpdate()

Syntax

Result = DatabaseUpdate(#Database, Request$)
Description
Executes the SQL 'Request$' on the #Database. This function is similar to DatabaseQuery() but is independent from the NextDatabaseRow() function. Therefore it's not possible to do a 'SELECT' like request with this function. This function is useful for updating records in the database. If Result is 0, then the query could not be executed correctly (due to a SQL fault or a badly-formatted query). The error text can be retrieved using DatabaseError()).

Example
  ; First, connect to a database with an employee table
  ;
  If DatabaseQuery(#Database, "SELECT * FROM employee") ; Get all the records in the 'employee' table
  
    While NextDatabaseRow(#Database) ; Loop for each records
      
      ; Update the 'checked' field for each records, assuming the 'id' field is 
      ; the first one in the 'employee' table
      ;
      DatabaseUpdate(#Database, "UPDATE employee SET checked=1 WHERE id="+GetDatabaseString(#Database, 0)) 
    Wend
    
    FinishDatabaseQuery(#Database)
  EndIf

Supported OS

All

<- DatabaseQuery() - Database Index - ExamineDatabaseDrivers() ->