.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Multiple web methods in one transaction

Posted By:      Posted Date: August 21, 2010    Points: 0   Category :ASP.Net

Hi everyone

Sorry I am kinda new in web services, so it may sound a bit newbish question.

We have a web service that comunicates with the database and exposes web methods that enables the application to access the database. Each method does only one operation (Insert, Update or Delete). What I need to do is create a transaction that will be consisted of multiple calls to the database, meaning multiple calls of more then one web methods. Can I do that? (I read that if the web method does not throw exception - or ContextUtil.SetAbort() is not called - the transaction will be commited automatically when the web method finishes executing, which I don't want to happen because I want to call another web method in the same transaction, and then manually commit the transaction)

Thank you in advance.

View Complete Post

More Related Resource Links

multiple executions of MERGE statement: Help with suitable TRANSACTION ISOLATION LEVEL

Folks, I am reasonably new to SQL Server. I am using SQL Server 2008 (no SP) on Windows XP. I am using the MERGE statement within a TSQL procedure to update a master/detail table pair (Master/Child), in which the MERGE inserts into the MASTER if a record based on the primary key doesn't exist and does, effectively nothing, if it does (well, it does an UPDATE set PK=PK so the record is passed on to the OUTPUT statement for insertion into the CHILD). Regardless as to the situation, the CHILD record has a record created when the MASTER exists or doesn't exist. Now, this code works fine with the standard TRANSACTION LEVELS. But I don't know what to do when I am running two instances of the same MERGE statement at the same time. One execution could create a record in the MASTER which the other process might try and create 5 minutes later. I really don't know what SET TRANSACTION ISOLATION LEVEL to use to allow both processes to run at the same time. I have looked at: ALTER DATABASE $(usedbname) SET READ_COMMITTED_SNAPSHOT ON; ALTER DATABASE $(usedbname) SET ALLOW_SNAPSHOT_ISOLATION ON; But these don't seem to work with their associated TSQL calls. I know this is a complex issue, but as a new SQL Server user, I didn't know where else to go. regards Simon                              

Multiple sql-statements in one transaction

Hi - I've two sql-statements - two inserts statements.The first one creates a person and the next creates an entry in another table with the person id as reference - everything works fine but I've been looking at my code and would like to know how I should wrap it up before firing the statements.I keep it all in one transaction - if the creating of the person fails or the other operation I need to rollbackMy question is:Should I use the same SqlCommand object to fire both statements? At this point I create a new instance for each statement - but isn't it possibly to use the same SqlCommand object, the same SqlConnection and wrap it into the same SqlTransaction?What is best practise in situations like this?

How to run multiple methods asyncronously and wait until all are finished?

I have this method:   public virtual List<User> GetUsersAsync(string[] usernames) { var result = new List<User>(); foreach (var username in usernames) { result.Add(this.GetUser(username)); } return result; }   Currently this method and GetUser run synchronously. How can I change this so that each GetUser runs asynchronously and GetUsers returns when all the GetUser() requests are completed? I know one way would be using delegate beginInvoke and endInvoke like this:   public virtual List<User> GetUsers(string[] usernames) { var result = new List<User>(); var delegates = new Dictionary<GetUserDelegate, IAsyncResult>(); // begin invoke all asynchronously foreach (var username in usernames) { var thisDelegate = new GetUserDelegate(GetUser); var asyncResult = thisDelegate.BeginInvoke(username, null, null); delegates.Add(thisDelegate, asyncResult); } // end invoke all foreach (var thisDelegate in delegates) { result.Add(thisDelegate.Key.EndInvoke(thisDelegate.Value)); } return result; }   this does work but seems to be a bit ugly code; what is the better way to do this? Thanks  

Dropping and linking multiple items within the same editing scope transaction

Hi, I'm using IActivityTemplateFactory.Create to provide a custom experience when the user drops a toolbox item onto my Flowchart designer.  The implementation of IActivityTemplateFactory.Create is to use the model item tree to programmatically create multiple model items (related to activities), and link them together using the appropriate model item properties and connector view state.  All this works fine except for one thing. Say I'm dropping three activities as a result of IActivityTemplateFactory.Create.  I want the first activity to appear at the top, underneath should be the second activity and below that the third activity.  I want all three activity designers to appear alighned around their center point and there to be a straight, centered connection arrow between activity one and two and another straight, centered connection arrow between two and three.  Here's some ASCII art (we'll see how the formatting is retained - not very well it seems): |-----------------| | Activity 1 | | | |-----------------| | | | \/ |--------------| | Activity 2 | |--------------| | | | \/ |----------| |Activity 3| |----------|  It's important to note that the activity designers all not all the same size; both the height and width can vary. I've written code that looks at the various activity

Multiple databases backup/restore in a transaction, if possible, into only one file


Hi dear,

I have three databases named XDW, XOLTP, XOLTPSchema. All of these are for only one application. In the application, user should do backup/restore using GUI.


1. How I should do backup/restore in one transaction? i.e. all of three actions should be success elsewhere all of them should fail.

2. Is it possible to backup them into only one file e.g. X.bak?

3. Or, What is the standard solution in this condition?

Thanks in advance.

How To: Joining multiple DataTable using “LINQ to DataSet”

Need to run mutiple WCF methods within a transaction


I need to run 5 different WCF methods but within a transaction. Is this possible in WCF? How can I do this in WCf, if it's possible?

The WCF methods will be called from the web service client, which could be an ASP.Net app or Winfoms app.

Dropping and linking multiple items within the same editing scope transaction - Part 2



In an earlier forum post, I asked about how to drop multiple items from the toolbox onto the design surface, have them arranged nicely, and do all this in a single editing transaction.  In that post, Kenny came up with a nice solution.

There's one more scenario that I didn't discuss in the earlier post, that I was hoping to be able to resolve on my own after getting the other post answered.  But, I I'm afraid I need some more help.

The scenario is the same as in the earlier post with one additional complication.  One of the items I'm dropping as part of the drag/drop operation is a FlowSwitch node.  If I did nothing else, the solution presented in the earlier forum post would work.  However, I've an additional need to visually change the appearance of the FlowSwitch designer. Normally, one can change an activity's designer (even a built in activity) by using the metadata store.  However, the FlowSwitch is unique in that the Flowchart designer has hard-coded knowledge of the FlowSwitch designer, and if you replace the built in designer via the metadata store, there are numerous places where the Flowchart designer will generate exceptions and pop up error messages.  I also have the need t

Running async WCF methods within a WCF transaction?


Can someone please tell me what is the correct way of calling async methods from within a WCF transaction?

Normally, one would only call synchronous methods from within a WCF transaction.


Accessing Multiple methods from a web service using web service task



When i am using an SSIS web service task, is it possible to get all the methods information to different tables.


Else if the above case is not possible, can i use multiple web service tasks with same http connection(.wsdl file) to access the web service for each method and then load the info to a table.(if i can do this, is there any performance issue)



Single Try/catch multiple methods


Hi All

I need to validate 3 different variables to see if they are valid dates and if they not tell me which one fails in the Catch.

 Method which takes a string and converts to datetime object below:-

public static DateTime dateConverter(string strDate)
            DateTime dt = new DateTime();

                if (strDate == "")
                    dt = Convert.ToDateTime("1900-01-01 00:00:00");
                    dt = DateTime.Parse(strDate).ToUniversalTime();

                return dt;
  static void Main()
                DateTime d = new DateTime();
                DateTime e;
                string w = "w";
                string valid = "2010-01-01 00:00:00";

                      d = dateConverter(w);
                      e = dateConverter(valid);
                catch(Exception c)
                   Console.WriteLine(*** "is a problem" + c.Data + c.Message + c.Source);



Where the *** in above I need which ever variable fails.

Multiple database support with Entity Framework

One of the features introduced in Entity Framework is being database independent. Which mean each database provider can support Entity Framework by implementing its provider.

This feature allows you build applications independent from the underplaying database provider. In this post I'm going to show how to build an application that support multiple databases using same conceptual model made by Entity Framework.

The Decorator Pattern & Extension Methods

The decorator pattern provides a formal way to add new functionality to an existing type, without sub-classing. First question: What is wrong with classical inheritance? In and of itself, nothing is wrong with the good old Is-A relationship. It is very common to derive a new class from an existing base class in order to override a few virtual members, and add a pinch of new functionality.

Binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Here is the code for binding the multiple drop down boxes in GridView using JQuery in ASP.NET

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Using jQuery to directly call ASP.NET AJAX page methods

Here I am looking to explain how to call page methods using jQuery. Using jQuery to directly call ASP.NET AJAX page methods

Adding Multiple Columns and Rows in GridView without using a Database

This article describes on how to add multiple columns and rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in each TextBoxes on Button Click and retain the GridView data on post back.

GridView Multiple Filter AJAX Control

This AJAX control enables the user to filter data within any column inside a GridView. The user can add multiple filters and can delete existing ones too.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend