AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Ayuda / WLanguage / Administrar bases de datos / Funciones SQL
  • 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
Reportes y ConsultasHyper 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
Reportes y ConsultasOLE 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
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/05/2022

Señalar un error o enviar una sugerencia | Ayuda local