PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Configuring 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
Redefines one or more connection parameters via Native Access (Access, SQL Server, MySQL or Oracle) or via an OLE DB access on a specific table or set of tables. Then, the tables are opened (or created if they do not exist). The specified test operation is run.
Notes:
  • The new definition of connection will be used until it is canceled by HConnect. It will be automatically canceled at the end of application.
  • By default, the connection characteristics are defined in the data model editor, for one or more tables.
Important
HConnect is used to easily define a connection to a database. We recommend that you use HDescribeConnection then HChangeConnection to:
  • manage the advanced parameters available for some databases (cursors, transactions, ...),
  • handle a named connection.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
WINDEVWEBDEV - Server codeReports and QueriesAjaxUser code (UMC)HFSQLHFSQL Client/ServerOLE DBNative Accesses
HConnect("Salaries", "", "", ...
"C:\My Documents\MyDatabase.mdb", "Microsoft.JET.OLEDB.4.0", hOReadWrite)
Windows Mobile
HConnect("salaries", "", "", "MyDatabase", "Microsoft.JET.OLEDB.4.0", hOReadWrite)
Syntax
<Result> = HConnect(<Table Name> [, <User Name> [, <Password> [, <Database> [, <OLE DB Server or Native Access> [, <Access> [, <Test Operation> [, <Optional Information>]]]]]]])
<Result>: Boolean
  • True if the operation was performed,
  • False if a problem occurred. HErrorInfo is used to identify the error.
<Table Name>: Character string (with quotes)
Name of table to open and for which the connection must be redefined. If no other parameter is specified, the data file is re-initialized with the default parameters defined in the analysis.
  • If this parameter is equal to "*", the change will be applied to all the tables handled by the native access (in this case, all the parameters of the connection must be specified)
  • If this parameter is equal to "*" and if no other parameter is specified, all the data files of all the native accesses defined in the analysis are re-initialized with the default parameters defined in the analysis.
<User Name>: Optional character string (with quotes)
User name that will be used to open the data file.
<Password>: Optional character string (with quotes)
Connection password (if this password exists).
<Database>: Optional character string (with quotes)
Full path of data source.
Windows Mobile Name of SQL Server CE or Oracle Lite database defined on Pocket PC.
<OLE DB Server or Native Access>: Optional character string or constant
Name of OLE DB provider or one of the following constants:
hAccessHF7Pseudo-connection to HFSQL Classic database
hAccessHFClientServerNative Access to HFSQL Client/Server database
hNativeAccessAS400Native AS/400 Access (optional module of WINDEV/WEBDEV)
hNativeAccessDB2Native DB2 Access (optional module of WINDEV/WEBDEV)
hNativeAccessInformixNative Informix Access (optional module of WINDEV/WEBDEV)
Versions 20 and later
hNativeAccessMariaDB
New in version 20
hNativeAccessMariaDB
hNativeAccessMariaDB
Native MariaDB Access (optional module of WINDEV/WEBDEV)
hNativeAccessMySQLNative MySQL Access (optional module of WINDEV/WEBDEV)
hNativeAccessOracleNative Oracle Access (optional module of WINDEV/WEBDEV)
hNativeAccessOracleLiteNative Oracle Access (optional module of WINDEV Mobile)
hNativeAccessPostgreSQLNative PostgreSQL Access (optional module of WINDEV/WEBDEV)
hNativeAccessProgressNative Progress Access (optional module of WINDEV/WEBDEV)
Versions 16 and later
hNativeAccessSQLAzure
New in version 16
hNativeAccessSQLAzure
hNativeAccessSQLAzure
Native SQL Azure Access (optional module of WINDEV/WEBDEV supplied with Native SQL Server Access)
Versions 15 and later
hNativeAccessSQLite
New in version 15
hNativeAccessSQLite
hNativeAccessSQLite
Native Access to SQLite database (supplied with WINDEV/WEBDEV)
hNativeAccessSQLServerNative SQL Server Access (optional module of WINDEV/WEBDEV)
hNativeAccessSQLServerMobileNative SQL Server Access (optional module of WINDEV Mobile)
hNativeAccessSybaseNative Sybase Access (optional module of WINDEV/WEBDEV)
hNativeAccessXBaseNative xBase Access (supplied with WINDEV/WEBDEV)
hNativeAccessXMLNative XML Access (supplied with WINDEV/WEBDEV)
hODBCOLE DB provider for ODBC (used to access an ODBC data source declared in the ODBC data sources of Windows)
hOledbAccess97OLE DB provider for Access 97
hOledbAccess2000OLE DB provider for Access 2000
hOledbAccess2007OLE DB provider for Access 2007
Versions 19 and later
hOledbAccess2010
New in version 19
hOledbAccess2010
hOledbAccess2010
OLE DB provider for Access 2010
hOledbDBase5OLE DB provider for dBase 5
hOledbExcel2007OLE DB provider for Excel 2007
hOledbExcel2000OLE DB provider for Excel 2000
hOledbExcel97OLE DB provider for Excel 97
hOledbLotus4OLE DB provider for Lotus 4
hOledbOracleOLE DB provider for Oracle
hOledbSQLServerOLE DB provider for SQL Server
Windows Mobile The available constants are as follows:
hAccessHF7Pseudo-connection to HFSQL Mobile database
hNativeAccessOracleNative Oracle Lite Access (optional module)
hNativeAccessSQLServerNative SQL Server CE Access (optional module)
OLE DB Caution: To use an OLE DB connection, you must:
  • install MDAC version 2.6 or later (setup performed by WINDEV/WEBDEV and when creating the setup program)
  • install the OLE DB provider corresponding to the database used.
    This parameter is returned by ..CtOLEDBProvider.
<Access>: Optional constant
Configures the type of access to the data file.
hOReadWrite
(default value)
The data file can be accessed in read/write. You have the ability to read the records and to write new records.
hOReadThe data file can be accessed in read-only. You only have the ability to read the records. No record can be added or deleted.
<Test Operation>: Optional constant
Configure the type of operation that will be performed on the database to check the connection.
hHCreationIfNotFound
(Default value)
Checks the connection by opening or creating a data file (if the data file does not exist). This operation can be performed in hOReadWrite mode only.
hHOpenChecks the connection by opening a data file. This value is used by default during an access to a database in hORead mode.
<Optional Information>: Optional character string
Information about the database. This information depends on the native access used.
Information inserted into the string for connecting to the database. For example, some data sources allow you to specify the database that will be used. With SQLServer, the "Master" database is the default database but other databases can be used, "dbo" for example. This information is specified in the <Optional Information> parameter via the following syntax:
OLE DB
"initial catalog = dbo"
ODBC
"database = dbo"
Native Accesses MySQL: "initial catalog = dbo"
Remarks

Configuring the connection

  • The table description must be known during the call to HConnect (the table must have been described in the analysis, or by HDeclare or HDescribeFile).
  • HConnect opens the connection and the table. The table is created if it does not exist. For this specific point, HConnect is equivalent to HCreationIfNotFound.
  • When redefining the connection, only the specified parameters are taken into account. The value of parameters not specified by HConnect corresponds to the value defined in the data model editor.
  • If only the <Table Name> is specified, HConnect cancels the re-definition of connection for the specified tables. The parameters specified in the data model editor will be applied.
  • When the <Table Name> parameter is equal to "*", the change applies to all the Native Access tables defined in the analysis. In this case, only the <User Name>, <Password>, <Database> and <Access> parameters are taken into account.
  • To cancel a connection change performed on the tables, <Table Name> must be equal to "*" and no other parameter must be specified.
  • If the data source is specified, HConnect ignores the possible HSubstDir/HChangeDir.
  • If a table is opened during the call to HConnect, the table is closed and re-opened with the new connection parameters.
Components
WINDEVWEBDEV - Server codeReports and Queries wd230hf.dll
Linux wd230hf.so
Windows Mobile wp230hf.dll
Minimum required version
  • Version 9
This page is also available for…
Comments
Example

Example
Nagyro.ini
======================
[Nagyro]
Server = 192.168.1.180
User = sa
Password = 777777777
BD = producao
======================


PROCEDURE DB_Inicialize(TrueFalse)

Server, User, Password, BD is string

IF TrueFalse = True THEN

PathFile is string = fCurrentDir(fCurrentDrive()) +"\Nagyro.ini"

IF fFileExist(PathFile) = True THEN

Server = INIRead("Nagyro", "Server", "", PathFile)
IF ErrorOccurred THEN
Error()
END

User = INIRead("Nagyro", "User", "", PathFile)
IF ErrorOccurred THEN
Error()
END

Password = INIRead("Nagyro","Password", "", PathFile)
IF ErrorOccurred THEN
Error()
END

BD = INIRead("Nagyro", "BD", "", PathFile)
IF ErrorOccurred THEN
Error()
END

HCloseConnection(ConnNativa)

ConnNativa..Server = Server
ConnNativa..User = User
ConnNativa..Password = Password
ConnNativa..Database = BD
ConnNativa..Provider = hNativeAccessSQLServer
ConnNativa..Access = hOReadWrite
ConnNativa..ExtendedInfo = "Extended information"
ConnNativa..CursorOptions = hClientCursor

ok is boolean = HOpenConnection(ConnNativa)

IF ok = False
Info(ErrorInfo())
Close()
END

END

END
adrianoboller
Feb. 09 2015