DB2 graphic QMF Version 8

Controlling QMF for Windows with APIs

The following steps describe how to work with the API to control QMF for Windows:

  1. Create an instance of the QMF for Windows API object.

    If you are using Microsoft Visual Basic, add a reference to the QMF for Windows type library, qmfwin.tlb. Then use the Dim statement:

    Dim QMFWin As New QMFWin

    Or, use the CreateObject statement:

    Dim QMFWin As Object
    Set QMFWin = CreateObject("QMFWin.Interface")

    If you are using Microsoft Visual C++ and MFC, create a wrapper class for the QMF for Windows API object from the QMF for Windows type library qmfwin.tle. Then use the CreateDispatch(() function:

    COleException e;
    IQMFWin QMFWin;
    QMFWin.CreateDispatch("QMFWin.Interface", &e);

    Note:
    If you are using a different development environment, refer to your product documentation on how to complete this step.
  2. Select the DB2 server you want to use and call InitializeServer() to initialize a connection to the database.
    Note:
    You cannot initialize a server until a user ID and password are validated by DB2. You can have QMF for Windows prompt for the user and password, or you can prompt for user information in your application and pass them as parameters in the InitializeServer() function call.
  3. Select the query you want to run using InitializeQuery(). If the query contains variables, use the SetVariables() function to set the variable values.
  4. Open or execute the query. Use the Open() function to open the query's cursor for SELECT statements. Use the Execute() function to execute the SQL for non-SELECT statements.
  5. If the query is a SELECT statement, fetch rows of data by repeatedly calling FetchNextRow(). To fetch more than one row at a time, use FetchNextRows(), or use CompleteQuery() to direct QMF for Windows to fetch all of the rows.
  6. If the query is a SELECT statement, close the query using the Close() function.
  7. Terminate the unit-of-work using the Commit() or Rollback() functions.


Go to the previous page Go to the next page

Downloads | Library | Support | Support Policy | Terms of use | Feedback
Copyright IBM Corporation 1982,2004 Copyright IBM Corporation 1982, 2004
timestamp Last updated: March, 2004