DatabaseQuery()
语法
Result = DatabaseQuery(#Database, Request$ [, Flags])概要
Executes a SQL query on the given database. Only queries which doesn't change the database records are accepted ('SELECT' like queries). To performs database modification, use DatabaseUpdate().
参数
#Database The database to use. Request$ The SQL query to execute. Flags (optional) The flags to use. It can be one of the following value: #PB_Database_StaticCursor : performs the query to access the result in a sequential manner. It's not possible to rewind with PreviousDatabaseRow() or FirstDatabaseRow() on some drivers, but it is the faster way to get the data (default). #PB_Database_DynamicCursor: performs the query to access the result in a random manner using PreviousDatabaseRow() or FirstDatabaseRow(). It can be slower, or even unsupported on some drivers.
返回值
Returns nonzero if the query was successful or zero if it failed (due to a SQL error or a badly-formatted query).
Remarks
If the query has succeeded then 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 get the number of columns returned by the query, use DatabaseColumns().
Once the query results aren't needed anymore, FinishDatabaseQuery() has to be called to release all the query resources.
示例
; 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
参阅
DatabaseUpdate(), NextDatabaseRow()
已支持操作系统
所有