DatabaseQuery()

Syntax

Result = DatabaseQuery(#Database, Request$)
Description
Executes the SQL Request$ on the #Database. If Result is 0, then the query can't be executed correctly (due to a SQL error or a badly-formatted query), otherwise the query has succeeded and NextDatabaseRow() can be used to list returned records (see the example below). In the event of an error, the error text can be retrieved with DatabaseError()). It is safe to use NextDatabaseRow() even if the request doesn't return any records. To execute a request that doesn't return any records, use DatabaseUpdate() instead of DatabaseQuery(). Once the query results aren't needed anymore, FinishDatabaseQuery() has to be called to release all the query resources.

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
      Debug GetDatabaseString(#Database, 0) ; Display the content of the first field      
    Wend
  
    FinishDatabaseQuery(#Database)
  EndIf

Supported OS

All

<- DatabaseID() - Database Index - DatabaseUpdate() ->