Now, these two operations are done with two different connections (say con1 and con2). Both these connections are enlisted in the same TransactionScope.
Before the delete/insert operations the connections are opened and immediately closed.
So, now if the insert fails, then how is the delete rollbacked since con1 has been closed?
I've got all of my ASP.NET requests wrapped in a Session and a Transaction that gets commited only at the very end of the request. At some point during execution of the request, I would like to insert an object and make it visible to other potential threads - i.e. split the insertion into a new transaction, commit that transaction, and move on. The reason is that the request in question hits an API that then chain hits another one of my pages (near-synchronously) to let me know that it processed, and thus double submits a transaction record, because the original request had not yet finished, and thus not committed the transaction record.
So I've tried wrapping the insertion code with a new SessionScope, TransactionScope(TransactionMode.New), combination of both, flushing everything manually, etc. However, when I call Refresh on the object I'm still getting the old object state. Here's some code sample for what I'm seeing:
Post outsidePost = Post.Find(id); // status of this post is Status.Old using (TransactionScope transaction = new TransactionScope(TransactionMode.New)) { Post p = Post.Find(id); p.Status = Status.New; // new status set here p.Update(); SessionScope.Current.Flush(); transaction.Flush(); transaction.VoteCommit(); } outsidePost.Refresh(); // refresh doesn't get the new status, status is still Status.Old
I have a requirement whereby I either have to perform and update or an insert on 1 table inside a transactionscope
There are 3 table in total, 2 will always be an insert, but 1 could be either an update or insert depending if some data already exists a foreign key relationship exists between all 3 tables (not on the same column though)
Im running an ASP.NET MVC application hosted with Mosso, there are telling me that they cannot enable DTC because they run everything in medium trust.So when executing code that references: TransactionScope I get the following error. The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)
we have a asp.net webforms app using NHibernate. Here are some specifics:We need Distributed Transactions because we write to the database as well as to a queue.Because this is a web app, we use the recomended Session-in-view pattern. We have a HTTPModule that opens the NHibernate session on the BeginRequest event and closes it on EndRequest.Within the flow of a request, we have several separate moments where we need to do transactional work. For this, we use TransactionScope.So basically, what happens is this (pseudocode):
using(var session = sessionFactory.CreateSession()){ using(var tx1 = new TransactionScope(){ //work work work
I am working on Sales application. In database i have SalesOrderHeader & SalesOrderDetail tables. They are almost typical Adventureworks db tables.
How to insert data in both tables using TransactionScope so if any of the record from the two tables generate error complete transaction roll-back.
One thing more I am using TableAdapters, My initial concept was inserting record in SalesOrderHeader, get SalesOrderId using Scope_Identity & bulkInsert Records to SalesOrderDetail using TransactionScope.
I have code that is supposed to do some database operations and then send an email through local iis smtp virtual server. All within one TransactionScope. It looks like
[Code]....
The second one where I use something similiar is
[Code]....
I want to notice that these events fire in the sequence they are shown. Now when there's an error, the db operations are rolled back, but the mail is sent anyway. I'm using Windows XP SP3, IIS 5.1, .Net 3.5, Visual Studio 2008. If I'm correct, TransactionScope uses MSDTC, right? I couldn't find anything about MSDTC working with smtp. Should it even work?
I'm writing some merge functionality in C# asp.NET MVC2. I am also using using Linq2SQL.
I have a block of code which calls two services, MessageService and UserService. These both in term call their appropriate repositories and make the amendments to the db. Each repository declares it's own instance of the repository so I'm thinking this will escalate the following code to DTC . The code is called from the AccountService, is this going to work at this level? And also is it bad practise to declare the DataContext at the top of every repository or should I pass the object around somehow? //Run the merge try { using (TransactionScope scope = new TransactionScope()) [code]....
I m using transactionscope and there was no problem until my domain changed.When it hits the scope7, it inserts the data and starts all over again and inserts for the second time.
Here is my sample code:
Using scope7 = New TransactionScope(TransactionScopeOption.RequiresNew) Dim comm As New Data.SqlClient.SqlCommand("INSERT INTO ABC (ID, AID, Type) VALUES (@ID, @AID, @Type)", conn) comm.Parameters.AddWithValue("@ID", TaskID) comm.Parameters.AddWithValue("@AID", FormID) comm.Parameters.AddWithValue("@Type", FormType) conn.Open() comm.ExecuteNonQuery() scope7.Complete()
User controls when rendered generates a dynamic ID for themselves. It makes sense also, as a page might have more than one of such user control and if dynamic id is not generated, there would be an ID conflict. But I am working on a page (legacy page yopu can say :D ) where I really need to specify a specific ID to usercontrol to make existing javascripts work. Is there a way to achieve this? OR if above is not doable (though I prefer it), below I have a dropdown in aspx like
I've build a query, but the where statement is doing strange things. First my query:
select * from ( SELECT 1 as Tag, null as Parent, row_number() OVER (ORDER BY tblOccasion.ID DESC) AS [tblOccasion!1!rownum], FROM tblOccasionwhere tblOccasion.UserID = @UserName and ((tblOccasion.MerkDesc like '%' + @search + '%')or(tblOccasion.UitvoeringDesc like '%' + @search + '%')or(tblOccasion.UitvoeringDesc like '%' + @search + '%')) ) AS A where a.[tblOccasion!1!rownum] BETWEEN (@startRowIndex) AND (@startRowIndex+@pageSize) order by a.[tblOccasion!1!MerkDesc!Element],a.[tblOccasion!1!TypeDesc!Element],a.[tblOccasion!1!UitvoeringDesc!Element] FOR XML EXPLICIT;
But the result should be ordered by Merkdesc, then TypeDesc, and then as last the uitvoeringDesc. So for testing i only used the MerkDesc. The strange thing is that i get the result:
BMW BMW BMW Opel Volvo
But this was page 1, on page 2 (paging) you got BMW again... so he takes the first 5 rows ore something and then the order. But i like that he first orders it by MerkDesc and then picks the first 5. How can i change that, i can't add a Order by in the inline sql statement i get this error: Msg 1033, Level 15, State 1, Procedure MijnAdvertenties, Line 47 De ORDER BY-component is ongeldig in weergaven, in line functies, afgeleide tabellen en algemene tabelexpressies, tenzij ook TOP of FOR XML is opgegeven.
I am confused about why I would need to wrap the DataContext's SubmitChanges within a transactionScope when modifying multiple tables. I was under the impression that the DataContext would track these changes and would therefore create its own transaction if need be.
In other words, if a change was made to update table A, B and C or if I made changes to 10 out of 20 items in a collection of rows, that the datacontext would track these changes and create its own transaction. If that is correct then why have I seen examples that wrapped these types of updates in a TransactionScope?
I had "Invalid viewstate" error in my application; I found out it's caused by worker process recycling, so I generated a <machinekey> section with explicit validationkey. refer to this link,[URL] My quesitons are 1. I have the application installed on dev, qa, stg and prd servers. Should I use the machinekey with the same(or different) validationkey for all the servers? I think it shouldn't be matter because the servers are independent from each other.
2. Where should I put the <machinekey> section, machine.config or individual application level's web.config? There are multiple applications on the server.
If I put it at the application level, does that mean other applications still may have the same "Invalid viewstate" error?
If I put it at the application level, should I add the <machinekey> section for all the other applications using the same validationkey?
Following the MVC1 vers of Nerddinner, but using 2010 and MVC2. Never seen this error. Looked in controller, model, view. Where does MVC pass the identity value, and how to stop it? I have never had to set IDENTITY_INSERT in any app before.
When I am clicking the button the Page_Load is calling twice. But if I am adding below code inside page load ,page load is calling only once on button click.
and return true is giving me again twice page load ,but adding return true or false in attribute.add code is giving the same result ,only one page load call.
Is there a way to use the .NET ScriptManager in Explicit mode to inlcude the CDN JQuery file(s)? There is plenty of dicussion and information about including the indivudual AJAX framework files such as "MicrosoftAjaxCore.js", but since AJAX uses JQuery, I thought there might be a way to explicitly include the JQuery file(s) using the ScriptManager rather than hard coding an address to the MS CDN.
when trying to translate the confirmation message to Norwegian i get the following error: Cannot have more than one binding on property 'OnClientClick' on 'System.Web.UI.WebControls.LinkButton'. Ensure that this property is not bound through an implicit expression, for example, using meta:resourcekey. i use Explicit localization in the following manner:
<data name="lnkMarkInvoicedResource.OnClientClick" xml:space="preserve"> <value>return confirm('Er du sikker?');</value>
if i remove the meta attribute i get the English text(default). how do i get the Norwegian text appearing without resorting to using the code behind? Update: removing the meta attribute prevents the exception from occurring but the original problem still exists. I can't get the Norwegian text to show. only the default English text shows.
Another Update: I know this question is getting old but i still can't get the Norwegian text to display.
The above things are simple but when I run the project. I got Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Cannot have more than one binding on property 'Text' on 'System.Web.UI.WebControls.Label'. Ensure that this property is not bound through an implicit expression, for example, using meta:resourcekey. Source Error: The above is just an example what I am facing in my project. how can I make localization and binding both at the same time.
I have an insert table with identity specification set. And I getthis error. I'm using a stored procedure to store it. How do I correct it. I'm also using a details view on my insert page.
Exception Details: System.Data.SqlClient.SqlException: Cannot insert explicit value for identity column in table 'Insert' when IDENTITY_INSERT is set to OFF.