ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Example: Modifying some ODBC connection parameters
  • Example: Modifying some OLE DB connection parameters
HConnect (Example)
Example: Modifying some ODBC connection parameters
WINDEVUser code (UMC)
In this example, the company database is on Oracle. The programmer wants to run the tests of his program on an SQL Server database by using the ODBC access.
Without modifying the analysis, the connection parameters can be modified by HConnect
Remark: "ODBCSQLServer" is an ODBC data source declared in the ODBC data sources of Windows.
// Change the connection parameters
HConnect("Salaries", "", "", "ODBCSQLServer", hODBC, hOReadWrite)
// Equivalent syntax:
HConnect("Salaries", "", "", "ODBCSQLServer", "MSDASQL", hOReadWrite)
// Start looping through the "Salaries" table on SQLServer
HReadFirst("Salaries")
...
// Restore the use of connection on Oracle
HConnect("salaries", "")
// Open the "Salaries" table on Oracle
HOpen("Salaries")
Example: Modifying some OLE DB connection parameters
WINDEVUser code (UMC)
In this example, the company database is on Oracle. The programmer wants to run the tests of his program on a local Access database.
Without modifying the analysis, the connection parameters can be modified by HConnect
In the analysis, a default OLEDB connection was associated to the "Salaries" OLEDB table on Oracle. The properties of this connection are:
  • datasource: oracleserver
  • user: smith
  • password: toto
  • provider: MSDAORA
The new connection toward the Access database will have the following parameters:
  • datasource: "C:\My Documents\MyDatabase.mdb"
  • user: ""
  • password: ""
  • provider: "Microsoft.JET.OLEDB.4.0"
// Change the connection parameters
HConnect(Salaries, "", "", ...
"C:\My Documents\MyDatabase.mdb", ...
"Microsoft.JET.OLEDB.4.0", hOReadWrite)
// Start browsing the "Salaries" table on Access
HReadFirst(Salaries)
...
// Restore the use of connection on Oracle
HConnect(Salaries, "")
// Open the "Salaries" table on Oracle
HOpen(Salaries)
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