Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.0 » QAnywhere » Creating QAnywhere Applications » Writing QAnywhere client applications » Initializing a QAnywhere API


Setting up .NET applications

Before you can send or receive messages using QAnywhere .NET clients, you must complete the following initialization tasks.

You must make two changes to your Visual Studio .NET project to be able to use it:

  • Add a reference to the QAnywhere .NET DLL. Adding a reference tells Visual Studio.NET which DLL to include to find the code for the QAnywhere .NET API.
  • Add a line to your source code to reference the QAnywhere .NET API classes. In order to use the QAnywhere .NET API, you must add a line to your source code to reference the data provider. You must add a different line for C# than for Visual Basic.NET.

In addition, you must initialize the QAnywhere .NET API.

To add a reference to the QAnywhere .NET API in a Visual Studio project

  1. Start Visual Studio and open your project.

  2. In the Solution Explorer window, right-click the References folder and choose Add Reference.

    The Add Reference window appears.

  3. On the .NET tab, click Browse to locate iAnywhere.QAnywhere.Client.dll. The default locations are (relative to your SQL Anywhere installation directory):

    • .NET Framework 2.0: Assembly\v2
    • .NET Compact Framework 2.0: ce\Assembly\v2

    Select the DLL and click Open.

  4. You can verify that the DLL is added to your project. Open the Add Reference window and then click the .NET tab. iAnywhere.QAnywhere.Client.dll appears in the Selected Components list. Click OK to close the window.

Referencing the data provider classes in your source code

To reference the QAnywhere .NET API classes in your code

  1. Start Visual Studio and open your project.

  2. If you are using C#, add the following line to the list of using directives at the beginning of your file:

    using iAnywhere.QAnywhere.Client;
  3. If you are using Visual Basic, add the following line to the list of imports at the beginning of your file:

    Imports iAnywhere.QAnywhere.Client

    This line is not strictly required. However, it allows you to use short forms for the QAnywhere classes. Without it, you can still use the fully qualified class name in your code. For example:

    mgr = 
     new iAnywhere.QAnywhere.Client.QAManagerFactory.Instance.CreateQAManager(
    "qa_manager.props" );

    instead of

    QAManager mgr = QAManagerFactory.Instance.CreateQAManager(
     "qa_manager.props" );

To initialize the QAnywhere .NET API

  1. Include the iAnywhere.QAnywhere.Client namespace, as described in the previous procedure.

    using iAnywhere.QAnywhere.Client;
  2. Create a QAManager object.

    For example, to create a default QAManager object, invoke CreateQAManager with null as its parameter:

    QAManager mgr;
    mgr = QAManagerFactory.Instance.CreateQAManager( null );

    For maximum concurrency benefits, multi-threaded applications should create a QAManager for each thread. See Multi-threading considerations.

    For more information about QAManagerFactory, see QAManagerFactory class.

    You can alternatively create a QAManager object that is customized using a properties file. The properties file is specified in the CreateQAManager method:

    mgr = QAManagerFactory.Instance.CreateQAManager( 
      "qa_mgr.props" );

    where qa_mgr.props is the name of the properties file that resides on the remote device.

  3. Initialize the QAManager object. For example:


    The argument to the open method is an acknowledgement mode, which indicates how messages are to be acknowledged. It must be one of IMPLICIT_ACKNOWLEDGEMENT or EXPLICIT_ACKNOWLEDGEMENT. With implicit acknowledgement, messages are acknowledged as soon as they are received by the client. With explicit acknowledgement, you must call the Acknowledge method on the QAManager to acknowledge the message.

    For more information about acknowledgement modes, see AcknowledgementMode enumeration.

You are now ready to send messages.


Instead of creating a QAManager, you can create a QATransactionalManager. See Implementing transactional messaging for .NET clients.

See also