PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Overview
  • Programming
  • 1. Establishing the connection
  • 2. Running queries
  • 3. Retrieving the result
  • 4. Closing the connection
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
Overview
The SQL functions can be used to handle the MySQL database.
Differences compared to HFSQL programming: The use of SQL functions to handle MySQL data does not require importing the file structure into the analysis. However, the data must be handled by queries only. The content of MySQL files cannot be read directly.
Remark: From version 19, HFSQL is the new name of HyperFileSQL.
Programming

1. Establishing the connection

SQLConnect is used to establish a connection to a MySQL database via the Native Connector. The type of database used (MySQL in this case) must be passed as parameter to SQLConnect.
Remark: The name of the MySQL data source ("MySQLDatabase" in this case) is the name or the IP address of the computer where the database is available. In any case, the name of the "Database" must be specified.
ConnectionNum = SQLConnect("MySQLDatabase", "", "", "", "MySQL")
// or ConnectionNum = SQLConnect("MySQLDatabase", "User", "Password", "MyDatabase", "MySQL")

// Connection to a remote MySQL database
ConnectionNum = SQLConnect("192.168.1.51", "User", "Password", "test", "MySQL")

2. Running queries

The queries are run by SQLExec. SQLExec expects the text of the SQL query as parameter, as well as the name that will be given to this query.
SQLExec("SELECT LASTNAME, FIRSTNAME, EXTENSION, PHOTO FROM CUSTOMER", "QRY1")

3. Retrieving the result

Several methods can be used to retrieve the result:
  • SQLFirst: Used to retrieve the result and initialize an SQLFirst/SQLCol browse.
  • SQLTable: Used to retrieve the result of the query in a memory table of the WINDEV application or WEBDEV site. The result of the query can be retrieved by partial Fetch.
  • SQLFetch: Used to browse the different lines of query result. The browse performed in the query result is an SQLFetch/SQLGetCol browse.
SQLLock is used to lock either the table records, or the records selected by the query. The timeout to lock or modify a locked record is set to 50s by default on MySQL. The database will return an error when the timeout is reached.

4. Closing the connection

SQLClose is used to close the connection to the database once all the necessary queries have been run.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment