ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Native Connectors/Native Accesses / Native SQL Server Connector
  • Overview
  • Programming
  • 1. Establishing the connection
  • 2. Running queries
  • 3. Retrieving the result
  • 4. Closing the connection
  • SQL Azure
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
SQL Server Native Connector: Programming using SQL functions
HFSQL ClassicHFSQL Client/ServerNot available with these kinds of connection
Overview
To use an SQL Server database with the Native Connector (or "Native Access"), you can use SQL functions.
Programming

1. Establishing the connection

SQLConnect opens a connection to an SQL Server database via the Native Connector. The type of database used, SQL Server in this case, must be passed as parameter to SQLConnect.
The database name corresponds to:
  • the name defined in WDSQSINS.
  • the name of the SQL Server server (or its alias).
    NumConnexion = SQLConnect("BaseSQLServer", "", "", "", "SQL SERVER")
Remarks:
  • By default, the installed version of the Native SQL Server Connector is used. If you have installed both the Native SQL Server Connector via OLE DB and via ODBC, the Native Connector via OLE DB will be used. You can select the version to use. The H.SQLServerMode variable is used to force a mode via the following values:
    • 0 to force the Native SQL Server Connector via OLE DB.
    • 3 to force the Native SQL Server Connector via ODBC.
    This variable must be modified before using SQLConnect.
  • SQL Azure: If the server name is of type: ServerName.database.windows.net, the login must be of the form: login@ServerName.

2. Running queries

The queries are run by SQLExec. SQLExec expects the text of the SQL query as parameter, as well as the name that will be given to this query.
SQLExec("SELECT LASTNAME, FIRSTNAME, EXTENSION, PHOTO FROM CUSTOMER", "QRY1")

3. Retrieving the result

Several methods can be used to retrieve the result:
  • SQLFirst: Retrieves the result and initializes a result path of type SQLFirst/SQLCol.
  • SQLTable: Retrieves the result of the query in a Table control populated programmatically in the WINDEV application. The result of the query can be retrieved by partial Fetch.
  • SQLFetch: Used to read the different lines of the query result. The query result path is of type SQLFetch/SQLLitCol.
SQLLock is used to lock the records found in the table or the records selected by the query.

4. Closing the connection

SQLClose is used to close the connection to the database once all the necessary queries have been run.

SQL Azure

SQL Azure requires the presence of a "clustered index" in the data files.
If you create the data files with SQL queries or to add a clustered index to an existing data file, see the documentation of SQL Azure to find out the syntax to use.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/21/2024

Send a report | Local help