- 1. Establishing the connection
- 2. Running queries
- 3. Retrieving the result
- 4. Closing the connection
- SQL Azure
Native SQL Server Connector: Programming with SQL functions
Not available with these kinds of connection
No matter whether WDSQSINS.EXE is used or not to configure the accessed database, the SQL functions can be used to handle the SQL Server database. For more details on WDSQSINS, see Configuring the connection with WDSQSINS
1. Establishing the connection
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).
ConnectionNum = SQLConnect("SQLServerDatabase", "", "", "", "SQL SERVER")
- 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:
This variable must be modified before using SQLConnect.
- 0 to force the Native SQL Server Connector via OLE DB.
- 3 to force the Native SQL Server Connector via ODBC.
- SQL Azure: If the server name has the following format: ServerName.database.windows.net, the login must have the following format: login@ServerName.
2. Running queries
The queries are run by 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: Used to retrieve the result and initialize an SQLFirst/SQLCol iteration.
- 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 iteration performed in the query result is an SQLFetch/SQLGetCol iteration.
SQLLock is used to lock the records found in the table or the records selected by the query.
4. Closing the connection
is used to close the connection to the database once all the necessary queries have been run.
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.
This page is also available for…