AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Administrar bases de datos / HFSQL / Funciones HFSQL
  • Example 1: Describing a connection on SQL Server via OLE DB
  • Example 2: Description of an ODBC connection to SQL Server via OLE DB
  • Example 3: Description of a connection to HFSQL Classic data files
HChangeConnection (Example)
Example 1: Describing a connection on SQL Server via OLE DB
WINDEVWEBDEV - Código ServidorReportes y ConsultasCódigo de Usuario (UMC)AjaxOLE DB In this example, the company database is on Oracle. The programmer wants to run the test of his program on an SQL Server database.
In the analysis, an OLEDB connection was associated with the "Salaries" OLE DB table on Oracle.
The properties of this connection are:
  • datasource: Oracle_Server
  • user: dupont
  • password: toto
  • provider: OraOLEDB.Oracle
The new connection to the SQL Server database will have the following parameters:
  • datasource: "Server_SQLServer"
  • database: "dbo"
  • user: ""
  • password: ""
  • provider: "SQLOLEDB"
Note: On SQLServer, you can define a database internal to the server data source.
// Describe the new connection
HDescribeConnection("MyConnection", "", "", ...
"Server_SQLServer", "dbo", hOledbSQLServer, hOReadWrite, "")
 
// Establish the new connection
HOpenConnection("MyConnection")
 
// Specify that "Salaries" uses the new connection
HChangeConnection("Salaries", "MyConnection")
 
// Start looping through the "Salaries" table on SQLServer
HReadFirst("Salaries")
...
// Close the connection
HCloseConnection("Salaries")
 
// Restore the use of connection on Oracle
HChangeConnection("Salaries", "")
 
// Open the "Salaries" table on Oracle
HOpen("Salaries")
Example 2: Description of an ODBC connection to SQL Server via OLE DB
WINDEVWEBDEV - Código ServidorReportes y ConsultasCódigo de Usuario (UMC)AjaxOLE DB The company database is on Oracle. The programmer wants to runt the test of his program on an SQL Server database by using the ODBC access via OLE DB.
Without modifying the analysis, you have the ability to change the connection used by the file.
Note: "ODBCSQLServer" is an ODBC data source declared in Windows ODBC data sources
// Describe the new connection
HDescribeConnection("MyConnection", "", "", ...
"Server_SQLServer", "dbo", hOledbSQLServer, hOReadWrite, "")
// Establish the new connection
HOpenConnection("MyConnection")
// Specify that "Salaries" uses the new connection
HChangeConnection("Salaries", "MyConnection")
// Start looping through the "Salaries" table on SQLServer
HReadFirst("Salaries")
...
// Close the connection
HCloseConnection("Salaries")
// Restore the use of connection on Oracle
HChangeConnection("Salaries", "")
// Open the "Salaries" table on Oracle
HOpen("Salaries")
Example 3: Description of a connection to HFSQL Classic data files
WINDEVWEBDEV - Código ServidorReportes y ConsultasCódigo de Usuario (UMC)AjaxHyper File 5.5OLE DB The company database is on Oracle. The developer wants to run the tests of his program on HFSQL Classic data files.
Without modifying the analysis, you have the ability to change the connection used by the file.
In the analysis, an OLEDB connection was associated with the "Salaries" OLE DB table on Oracle.
The properties of this connection are:
  • datasource: Oracle_Server
  • user: dupont
  • password: toto
  • provider: OraOLEDB.Oracle
The new pseudo-connection (using an HFSQL Classic database) will have the following parameters:
  • datasource: "c:ASLASH_Tmp"
  • database: ""
  • user: ""
  • password: ""
  • provider: hAccèsHF7
// Describe the new connection
HDescribeConnection ("MyConnection", "", "", "c:\tmp", "", ...
	hAccessHF7, hOReadWrite, "")
// Specify that "Salaries" uses the new connection
HChangeConnection("Salaries", "MyConnection")
// Start looping through the "Salaries" table on SQLServer
HReadFirst("Salaries")
...
// Close the file
HClose("Salaries")
...
// Restore the use of connection on Oracle
HChangeConnection("Salaries", "")
// Open the "Salaries" table on Oracle
HOpen("Salaries")
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/03/2025

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