>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User

# Connection and Statement Handles

You start accessing a database by first opening a connection to the data source. The result is a number, called the connection handle. Subsequent requests to the data source use this connection handle.

When you send a request to select some data, the result is also a number, called the statement handle. Again, subsequent requests that reference this selection use the statement handle. There may be more than one statement handle associated with a connection handle. You may also have a statement handle not associated with a connection handle, where the request made was not specific to a particular data file.

In both cases, you should close the handle to free up resources when you are finished with it. For example, to read records from a file, you typically:

- open a connection to the data source, returning a connection handle
- make a selection on a specific file using the connection handle, returning a statement handle
- read the records, using the statement handle
- close the statement handle
- close the connection handle

  You must always close a connection handle explicitly. However, a statement handle may be closed if you have fetched all records selected - see the discussion of `ddfet` below. In any case, it is good practice to always close the statement handle explicitly, as there is no harm done if you try to close a handle that had already been closed.

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help User