Contents IndexDDE concepts Excel and WSQL DDE Server

User's Guide
   Part V. The SQL Anywhere Programming Interfaces
     Chapter 37. The WSQL DDE Server
      Using WSQL DDE Server

The WSQL DDE Server executable has the file name WSQLDDE.EXE, and will usually be run from your c:\sqlany50 directory.

Top of page


The WSQL DDE Server window

The WSQL DDE Server window consists of an output window and a menu bar. The output window is updated every time WSQL DDE Server processes a command. It also displays any errors which have occurred. (If an error occurs, a message box will also inform you.) Every line of the output window begins with the DDE conversation number of the application which sent the command or caused the error. The output window will display the last five hundred commands and errors.

The menu bar has one item, File, which has the following selections:

Top of page


Initiating a DDE conversation with WSQL DDE Server

A DDE conversation must be initiated before exchanging data using WSQL DDE Server. Two pieces of information are used to initiate a conversation with WSQL DDE Server: the service name and the topic name.

Database connection is separate
The database is not activated or connected to when the DDE conversation is initialized. This occurs when the Connect command is sent.

Top of page


Communicating with the WSQL DDE Server

Once a conversation is initiated, there are three ways of communicating with WSQL DDE Server: poking, executing and requesting. The three methods are documented on the following pages.

Poking commands to WSQL DDE Server

Poking sends two pieces of data from the client application to WSQL DDE Server: a data buffer and an item name specifying what to do with the data.

     POKEitem-name data-buffer

There are five WSQL DDE Server functions which you can access through poking: Connect, Disconnect, Add, Clear and Clip.

Connecting to a database

     POKE CONNECT

Before any queries or commands can be sent to the database engine, you must connect to the database. To do this, set the item name to Connect. WSQL DDE Server will attempt to connect to the database environment mentioned in the DDE topic. If the database engine is not running, then WSQL DDE Server will attempt to start it.

If there is no database name mentioned in the topic, then WSQL DDE Server will try to connect to an already-running database engine. (If there is no running engine, then the connect will fail.)

The contents of the data buffer are ignored.

One connection only
It is not possible to have more than one connection per conversation.

Disconnecting from a database

     POKE DISCONNECT

To terminate the current connection, set the item name to Disconnect. The contents of the data buffer are ignored.

Terminate the conversation separately
This command terminates the connection to the database, but does not terminate the DDE conversation (though it will usually be the last command sent in a DDE conversation).

Adding to the query buffer

     POKE ADDtext

Some applications (such as Excel) can only poke 255 characters at a time. Many SQL queries, however, are longer than this. For this reason, WSQL DDE Server allows an application to build a complete query string by adding together many shorter strings. To add text to the query buffer, set the item name to Add and the data buffer to the text you wish to add to the buffer.

Each DDE conversation has its own query buffer.

Clearing the query buffer

     POKE CLEARtext

To reset the query buffer, set the item name to Clear and the data buffer to the string you wish to place at the beginning of the query buffer.

Putting query results on the clipboard

     POKE
               CLIP_DATA
              | CLIP_COLUMN_NAMES
              | CLIP_COLUMN_NAMES_AND_DATA
          ... [ text ]

There are three very similar commands which put the results of a query on the clipboard. Each adds the contents of the data buffer to the query buffer, and then evaluates the query stored in the query buffer. The results of the query are formatted and placed on the clipboard. Most applications have a Paste command which will retrieve the query results from the clipboard.

The three commands are:

Clip_Data place the results of the query on the clipboard in text format. Each datum will be separated by a tab character. Each row will be terminated by a newline character.

Clip_Column_Names place the names of the columns referenced in the query onto the clipboard. Column names will be separated by tab characters, and the row will be terminated by a newline character.

Clip_Column_Names_And_Data does both operations, appending the data after the column names.

Executing database commands

     EXECUTE[ text ]

Executing a command adds the command to the query buffer and sends the contents of the query buffer directly to the database engine. It is very similar to doing an EXECUTE IMMEDIATE from Embedded SQL. Executed commands do not return results to the application, so queries cannot be executed. Item names are ignored when doing a DDE execute transaction.

Requesting

     REQUEST    

          DATA
              | COLUMN_NAMES
              | COLUMN_NAMES_AND_DATA

Requesting data gives the calling application a block of memory containing the requested data, as opposed to placing the data on the clipboard for the application to access. (This is useful for applications that do not support clipboard access.)

WSQL DDE Server only supports cold request links. (That is, it is the application's responsibility to request data. See the section on DDE above for more information about link types.) WSQL DDE Server places the results of the query currently in the query buffer into a memory block and then sends the address of the memory to the application.

There are three valid item names for the request transaction: Data, Column_Names and Column_Names_And_Data. The structure of the data in the buffer is identical to that of the data placed on the clipboard when doing a Clip_Data, Clip_Column_Names or Clip_Column_Names_And_Data command. (See above.)

Top of page


Contents IndexDDE concepts Excel and WSQL DDE Server