PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Connection with a HFSQL analysis
  • Various
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Closes the current connection and frees the memory used by the connection. SQLDisconnect must be systematically called to close the connection, even if this connection failed.
Example
Reports and QueriesHFSQLHFSQL Client/ServerHyper File 5.5
// Example associated with the SALESMGT analysis
// TABLE_QryTable is a memory table
ResConnect is int
ResExec is boolean
MyDatabase is string = "C:\SALESMGT.WDD"
ResConnect = SQLConnect(MyDatabase, "", "")
IF ResConnect <> 0 THEN
ResExec = SQLExec("SELECT NAME, CITY FROM POP", "QRY1")
IF ResExec = True THEN
// Retrieve the data in the table
SQLTable("QRY1", TABLE_QryTable)
ELSE
// Error while running the query
// Retrieve information about the query run
SQLInfo("QRY1")
Error(SQL.MesError)
END
// Free the query in any case
SQLClose("QRY1")
ELSE
 // Connection error
 Error("The connection to the database" + MyDatabase + " failed")
END
// Free the query in any case
SQLDisconnect()
Syntax
SQLDisconnect()
Remarks
Reports and QueriesHFSQLHFSQL Client/ServerHyper File 5.5

Connection with a HFSQL analysis

During a connection with a HFSQL analysis, SQLDisconnect closes the analysis (equivalent to HCloseAnalysis). To continue to use the analysis files, the analysis must be opened by HOpenAnalysis.
Note: From version 19, HFSQL is the new name of HyperFileSQL.

Various

  • A single connection can be established at a given time.
  • The memory allocated during the connection (execution of "SQLFreeConnect") is automatically freed.
Component : wd240hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Example with SQLConnect/SQLExec/SQLDisconnect
ConnectionNum is int
SourceName is string
// Connection to a specific data source via ODBC MS ACCESS
SourceName = "MS Access 97 Database"
ConnectionNum = SQLConnect(SourceName, "", "", "", "ODBC") // <--------
IF ConnectionNum <> 0 THEN
// The connection was successful

// Run the query and retrieve the result line by line
i is int = 0
SQLExec("SELECT LASTNAME, FIRSTNAME, EXTENSION, PHOTO FROM CUSTOMER", "QRY1") // <--------
WHILE SQLFetch("QRY1") = 0 // There is still another line to read
i++
// Retrieve the data
LASTNAME[i] = SQLGetCol("QRY1", 1)
FIRSTNAME[i] = SQLGetCol("QRY1", 2)
EXTENSION[i] = SQLGetCol("QRY1", 3)
{"IMAGE"+i} = SQLGetMemo("QRY1", 4)
END
SQLClose("QRY1")

ELSE
// The connection failed: display an error message
SQLInfo()
Error("The connection to the data source " + SourceName + " failed." + CR + ...
"Error code: " + SQL.Error + CR + SQL.MesError)

END
// In any case (connection OK or not)
SQLDisconnect() // <--------
BOLLER
11 Sep. 2018