ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / SQL functions
  • Example 1: Connection to an HFSQL database
  • Example 2: Connection via a native access
  • Example 3: Connection via ODBC
  • Example 4: Connection via JDBC
  • Example 5: Connection via OLE DB
  • Example 6: Connection to a Hive server
SQLConnect (Example)
Example 1: Connection to an HFSQL database
Reports and QueriesHyper File 5.5
This example is used to handle an HFSQL database via an SQL connection.
ConnectionNum is int
FullWddName is string
WddPassword is string
TestVariable is string
 
// Path of the analysis
FullWddName = fCurrentDir() + "\MyAnalysis.ana\MyAnalysis.WDD"
 
// Password defined in the analysis for the WDD (if a password is defined)
WddPassword = "PASSWDD"
 
// Connection to the HFSQL database
ConnectionNum = SQLConnect(FullWddName, "", WddPassword, "Hyper File")
IF ConnectionNum <> 0 THEN
// The connection was successful
// Use the connection to run SQL queries
TestVariable = "DOE"
IF SQLExec("SELECT * FROM CUSTOMER WHERE NAME='" + TestVariable + "", ...
 "FINDCUSTOMERBYNAME") = True THEN
 // Process the query
ELSE
  // Query failure: display an error message
  SQLInfo("FINDCUSTOMERBYNAME")
  Error("Error" + SQL.Error + "in the query: ", SQL.MesError)
END
ELSE
 // The connection failed: display an error message
SQLInfo()
Error(SQL.MesError)
END
// Mandatory, whether the connection is OK or not
SQLDisconnect()
Example 2: Connection via a native access
Example 3: Connection via ODBC
Example 4: Connection via JDBC
Example 5: Connection via OLE DB
Reports and QueriesOLE DB
This example is used to handle an SQL Server database via an OLE DB connection.
ConnectionNum is int
ConnectionNum = SQLConnect("127.0.0.1", "sa", "", "master", "OLEDB", hOledbSQLServer)
IF ConnectionNum <> 0 THEN
// The connection was successful
Info("The connection was successful")
ELSE
// The connection failed: display an error message
SQLInfo()
Error("The connection to the data source failed." + CR + ...
"Error code: " + SQL.Error + CR + SQL.MesError)
END
// In any case (connection OK or not)
SQLDisconnect()
Example 6: Connection to a Hive server
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