PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • HFSQL analysis connection
  • Miscellaneous
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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
HFSQLHFSQL Client/Server
// Example associated with the SALESMGT analysis
// TABLE_QryTable is a Table control populated programmatically
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
HFSQLHFSQL Client/Server

HFSQL analysis connection

In a connection with an HFSQL analysis, SQLDisconnect closes the analysis (same as HCloseAnalysis). To continue to use the analysis files, the analysis must be opened by HOpenAnalysis.

Miscellaneous

  • A single connection can be established at a given time.
  • The memory allocated during the connection (execution of "SQLFreeConnect") is automatically freed.
Component: wd270hf.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