Asynchronus function calls - I think

Posted on 2007-07-20
Last Modified: 2010-03-19
We have a web service on a Windows 2003 server running that is running transactions against another server with SQL Server 2005 installed on it.  My problem is that I have a function that copies one record into another and then end dates the previous record.  Following this, I have a series of updates statements that run against the new copy of the record so that we have a complete history with date tracking.

The interesting part comes when the webservice runs the copy function and once it thinks it's finished it continues on to the update function.  However, the insert function isn't finished writing to the server so none of the updates are processed.  I've tried try and catch statements and in the end had to put a two second delay on my page that was calling the functions.  Is anyone else having this problem?
Question by:NBAIS
    LVL 4

    Accepted Solution

    have you tried begin transaction and commit transaction method. It will clear the doubt what u assume. may be it is some bug in the web part.

    By this u can narrow down, from where the issue is coming from.


    Author Comment

    Though the web methods call sql statements, they're not calling stored procedures.  The sql is being stored as a string and then executed from the web method.  By doing it in this manner, it may actually be what is causing our problem in the first place.  I'm sure stored procedures run qutie a bit faster.
    LVL 4

    Expert Comment

    it is easier to call Stored Procedure too. Try BEGIN TRANSACTION AND COMMIT TRANSACTION in the stored Procedure and you will find out.

    Be careful that this can cause a lock on the database which can get excalated to Shared lock and later exclusive lock.

    This depends on how fast the transaction are and how big is ur database.

    Rosh K. M.
    LVL 4

    Expert Comment

    ... in the stored Procedure and you will find out where the bug is ....

    Rosh k. M.

    Author Comment

    Thanks for the help.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Suggested Solutions

    Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 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

    19 Experts available now in Live!

    Get 1:1 Help Now