PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • Overview
  • Importing the structure of files
  • The import steps
  • Taking into account the evolution of the SQL Server database
  • Programming
  • 1. Establishing the connection
  • 2. Running queries
  • 3. Retrieving the result
  • 4. Closing the connection
  • Optimization
  • SQL Azure
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
Native SQL Server Connector: Programming with HFSQL functions
HFSQLHFSQL Client/ServerNot available with these kinds of connection
Overview
To use an SQL Server database with Native Connector, the structure of SQL Server tables must be imported into the data model analysis.
Differences compared to SQL programming: The queries are not required to handle the SQL Server data. Indeed, the HFSQL functions can be directly used to read data, perform searches, implement filters, ... However, the structure of SQL Server files must be imported into the data model editor.
Note: From version 19, HFSQL is the new name of HyperFileSQL.
Importing the structure of files

The import steps

To perform this import:
  1. Open the data model editor ("Project .. Load the analysis"). Start the data model editor: click Analysis icon among the quick access buttons.
  2. In the data model editor, select "Structures of files .. Import the descriptions of files/tables".On the "Analysis" pane, in the "Creation" group, expand "Import" and select "Import the descriptions of files/tables".
  3. The wizard starts. A connection to the SQL Server database is automatically established and associated with the files imported into the analysis. This connection will be used to handle the SQL Server data file by programming.
In the different wizard screens, choose the following options:
  • Data source: External database.
  • The data in current format will be used by the application.
  • Select the "Native Access for SQL Server" type, the data source, the user name and the password. The "Properties" button is used to access the system properties.
  • When the connection is established, select the tables that will be imported into the analysis. These tables can be handled by programming with the HyperFileSQL functions of WLanguage. These tables will be displayed in blue in the data model editor.
In the different wizard screens, choose the following options:
  • Database Type: SQL Server.
  • Characteristics of the connection: Data server, User and password, database.
  • The application will access the data in the current format.
  • When the connection is established, all you have to do is select the tables that will be imported into the WINDEV or WEBDEV analysis. These tables can be handled by programming with the HFSQL functions of WLanguage. These tables will be displayed in blue in the data model editor.

Taking into account the evolution of the SQL Server database

To take into account the evolutions of tables imported into the data model editor, select "Structure of files .. Synchronize the analysis with the external databases". To take into account the evolutions of the tables imported into the data model editor, on the "Analysis" pane, in the "Analysis" group, expand "Synchronization" and select "Update the analysis from the external databases".
A wizard starts, allowing you to:
  • analyze the differences for the imported tables.
  • analyze the differences for all the SQL Server tables.
Programming

1. Establishing the connection

To establish the connection with the SQL Server database, use HOpenConnection and specify the name of the connection to open. The connection name was defined when importing the structure of files into the analysis.
To modify some parameters of this connection (user name or password for example), call HConnect.
Notes:
  • If you try to read the file directly (HReadFirst, ...), the connection associated with the file description in the analysis will be automatically opened.
  • If you own the two versions of the Native SQL Server Access, you have the ability to select the version that will be used. By default, the Native Access via DB-Library is used if it is installed on the computer ; otherwise, the Native Access via SQLnCli is used. The H.SQLServerMode variable is used to force a mode with the following values:
    • 0 to force the Native Access via SQLnCli.
    • 1 to force the Native Access via SQLnCli if it is installed ; otherwise, the Native Access via DB-Library will be used.
    • 2 to force the use of the Native Access via DB-Library.
      This variable must be modified before using HDescribeConnection and/or HOpenConnection.
  • If you own the Native SQL Server Access via SQLnCli, you have the ability to use specific extended information (in HOpenConnection or in HDescribeConnection):
    • WD Cache Size: Defines the number of records that must be read at the same time by a server cursor. This value is set to 100. by default
    • WD Cursor Location: If "WD Cursor Location = SERVER", gives you the ability to use a server cursor for all the browses performed on this connection. The type of the server cursors used is FAST_FORWARD. See the documentation about SQL Server for more details. This type of cursor can be used to:
      - Limit the resources reserved on the server during the browse operations.
      - Limit the number of connections opened by the native access to manage the multiple browses in parallel.
      Caution:
      • In most cases, the browses performed with the server cursors are slower than the browses performed in default mode.
      • The server cursors may not be compatible with some types of queries.
      • The performances are affected by the size of the cache.
        Note: The server cursors are automatically used when a connection is in transaction.
  • Versions 16 and later
    SQL Azure: If the name of the server is such as: ServerName.database.windows.net, the login must have the following format: login@ServerName.
    New in version 16
    SQL Azure: If the name of the server is such as: ServerName.database.windows.net, the login must have the following format: login@ServerName.
    SQL Azure: If the name of the server is such as: ServerName.database.windows.net, the login must have the following format: login@ServerName.

2. Running queries

HExecuteQuery and HExecuteSQLQuery are used to run queries on the current database.
  • HExecuteQuery: is used to run a preset query with the query editor.
  • HExecuteSQLQuery: is used to run a query by specifying the SQL code of query and the name that will be assigned to this SQL code.
// Initialize the "Customer_84" query
HExecuteQuery(CUSTOMER_84, "SQLServerDatabase", hQueryWithoutCorrection)
HExecuteSQLQuery(CustomerQry, "SQLServerDatabase", hQueryWithoutCorrection, ...
"SELECT NAME FROM CUSTOMER")

3. Retrieving the result

The result is browsed by the standard read functions: HReadFirst, HReadNext, HReadSeek, ...
The records cannot be locked by the lock options of these functions.

4. Closing the connection

HCloseConnection is used to close the connection to the database when all the necessary queries have been run.

Optimization

  • The "Browsing table" controls based on queries are optimized: the content of the Table control can be sorted by clicking one of its columns.
  • To avoid re-running the same query several times when browsing its result, we advise you to use the hNoRefresh constant (if the data is modified by a single computer for example).
  • Each browse on a key requires the creation of a "cursor". This "cursor" is run in an SQL SERVER "task". To avoid storing useless processes on the server, we recommend that you use:
Versions 16 and later

SQL Azure

SQL Azure requires the presence of a "clustered index" in the data files.
If the data files are created by HCreation, the Native Access automatically creates the "clustered index" if the description of the data file contains an automatic identifier.
New in version 16

SQL Azure

SQL Azure requires the presence of a "clustered index" in the data files.
If the data files are created by HCreation, the Native Access automatically creates the "clustered index" if the description of the data file contains an automatic identifier.

SQL Azure

SQL Azure requires the presence of a "clustered index" in the data files.
If the data files are created by HCreation, the Native Access automatically creates the "clustered index" if the description of the data file contains an automatic identifier.
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment