Multi-threaded COM Component

Posted on 2004-11-08
Last Modified: 2013-11-25
I have to write an ATL COM component in vc++ which will reside in a central location. This component has to handle the database request from various client simoultaneously. How can manage multiple request? . Just making the component as a multi-threaded one will handle it?.  Can I open a database connection in the Run() method in the CServiceModule class and use it .
Will this single database connection pointer will handle the multiple request?

Question by:GKY
    1 Comment
    LVL 1

    Accepted Solution

    If you are using SQL server2000 you can use any of this words to admin your database locks just after the clausule FROM 'Tabla' WITH 'nolock'

    FASTFIRSTROW—The query is optimized to get the first row of the result set.
    HOLDLOCK—Hold a shared lock until the transaction has been completed.
    NOLOCK—Do not issue shared locks or recognize exclusive locks. This may result in data being returned that has been rolled back or has not been committed; therefore, working with dirty data is possible. This may only be used with the SELECT statement.
    PAGLOCK—Locks the table.
    READCOMMITTED—Read only data from transactions that have been committed. This is SQL Server's default behavior.
    READPAST—Rows locked by other processes are skipped, so the returned data may be missing rows. This may only be used with the SELECT statement.
    REPEATABLEREAD—Locks are placed on all data used in queries. This prevents other users from updating the data, but new phantom rows can be inserted into the data set by another user and are included in later reads in the current transaction.
    ROWLOCK—Locks the data at row level. SQL Server often locks at the page or table level to modify a row, so developers often override this setting when working with single rows.
    TABLOCK—Lock at the table level. You may want to use this when performing many operations on table-level data.
    UPDLOCK—Use update locks instead of shared locks while reading a table, and hold locks until the end of the transaction. This has the advantage of allowing you to read data without locking and to update that data later knowing the data has not changed.
    XLOCK—Uses an exclusive lock on all resources until the end of the transaction.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Title # Comments Views Activity
    post4 challenge 28 69
    hasOne  challenge 59 62
    strDist challenge 35 69
    firstChar challenge 13 55
    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now