ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Example: Initializing and browsing an SQL query
  • Example: Connecting to an SQL Server database and executing a query
HExecuteSQLQuery (Example)
Example: Initializing and browsing an SQL query
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)PHPAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBNative Connectors (Native Accesses) The following example is used to initialize a query and to browse it. This example uses the Data Source type to handle the query.
MyQuery is Data Source
// Initializes the query
IF NOT HExecuteSQLQuery(MyQuery, ...
"SELECT LASTNAME,FIRSTNAME FROM CUSTOMER WHERE CUSTOMER.LASTNAME = 'SMITH'") THEN
Error("Error while initializing the query" + CR + HErrorInfo())
RETURN
END
 
// Read the first record of the query
HReadFirst(MyQuery)
WHILE NOT HOut()
  // Process on the query record
  // Access to the items via MyQuery.<Item name>
  ...
  // Read the next record
  HReadNext()
END
Example: Connecting to an SQL Server database and executing a query
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)PHPAjax
CustomerQry is Data Source
IF NOT HDescribeConnection("MyConnection", "sa", "","NATIVESQL", "", ...
hNativeAccessSQLServer, hOReadWrite) THEN
    Error(HErrorInfo())
ELSE
    // Open the connection
    HOpenConnection("MyConnection")
    HourGlass()
    // Execute query
    IF HExecuteSQLQuery(CustomerQry, "MyConnection", hQueryDefault, ...
"SELECT * FROM Store") THEN
      // Browse the result
      HReadFirst(CustomerQry)
      IF NOT HOut(CustomerQry) THEN
        FileToMemoryTable(TABLE_MyTable, ...
CustomerQry)
      END
    END
    HourGlass(False)
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help