C# - Difference Between Transaction Scope And Manually Defined Transactions ?

Jul 22, 2010

just reading about using transaction scrope, previously I am used to making transactions inside a single DB class like

try
{
con.Open();
tran = con.BeginTransaction();[code]...

Which one is the recommended coding practice and why ? Is using a Transaction Scope safe ? Is it the latest way to do things ? I am confused about both methods.

View 1 Replies


Similar Messages:

SQL Server :: Any Alternatives Of Using Transaction Scope

Jan 24, 2011

I have a multiple database operation, Have three tables (MSsql) and need to delete one row in each table in one operation, one after another. (Three functions, three rows of code). Everything is working as it should be, recently I was advised to use a transaction scope, which should guarantee the safety of deletion from all 3 tables together.
Here is my new code:
[Code]....

Locally all worked just fine, the transaction scope worked well, but when I have uploaded my application to my hosting server, I got an error of: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025).I talked with the host support, they tried to do something, then I got this error: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

After a 2 days, They have contacted me, they said it is not possible to disable some restriction, that will allow an access to this operation, because I'm using shared hosting, and I need to upgrade my plan to VPS. VPS is a very expensive for me, and I can't afford it, What I'm looking is a some similar way of doing the same operation as transaction scope do, that may work at my hosting, At least I would like to try something else. Is there any additional way for the transaction scope?

View 1 Replies

Send SMTP From With A C# TransactionManager Transaction Scope?

Oct 25, 2010

Trying to troubleshoot a questionable plugin a client is experiencing issues with in production, and one possible issue I see is the fact that they're sending SMTP synchronously from within our heavily-transacted C# web application. In the past I believe I've read or been told that sending SMTP synchronously from within a transaction is a precarious bet, but I can't seem to find anything to back it up that I can present to the client's dev team.

View 1 Replies

Is Context.Items User Scope Or Application Scope

Apr 6, 2010

I want to use Context.Items to store some info of a User Control like:

Context.Items["Data"] = 5;

I want to know, Is Context.Items is for each request or it is global for the application?

View 1 Replies

Flush Separate Castle ActiveRecord Transaction And Refresh Object In Another Transaction

Jun 15, 2010

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

View 1 Replies

Page Scope Variables In .NET?

Dec 7, 2010

I need to access some variables in a page in web application. The scope of variables is just in that specific page.
which one is the solution ? Session or ViewState ? or any better solution ?

Private Property UserId() As Integer
Get
If Not ViewState("UserId") Is Nothing Then[code]....

And also Is ViewState custom per user?

View 1 Replies

MVC :: Strategies For Managing Security Scope?

May 17, 2010

In this case I have a system where a user logs in, they get a dashboard and they can see all their related projects. The user can click on the project and open it. (ie /View/79) The problem the user can also just type /View/68 which they are not supposed to be able to view.

Obviously I am aware of how to filter my data, but this application has many many lists of data and it all needs to be scoped to data that user has been allowed to see. I can insert a plethora of joins and wheres in all my queries but.. it's a lot of work and a bit convoluted.So I was wondering what strategies other had used for filtering data based on the user scope.One approach I was thinking of was to extend my user-role-permission model so "permissions" could be assigned to various entitites (like projects). This way, rather than doing a series of joins etc to see confirm a user has been assigned to a project, my join is just onto the EntityPermission table to confirm the user has PermissionX (like: CanView) on that entity. I could either maintain a seperate M2M table for each entity i need to restrict or something a bit more general (but without referential integrity).

View 3 Replies

Retrieve Web User's Identity Outside Of Request Scope?

Feb 14, 2011

I have an ASP.NET app that logs Audit reports using nHibernate's IPreUpdateListener. In order to set the current user in the Listener events, I was using System.Security.Principal.WindowsIdentity.GetCurrent(). This works fine when debugging on my machine, but when I move it to the staging server, I'm getting the ASP.NET process credentials, not the requesting user.

In the ASP.NET page, I can use Request.LogonUserIdentity (which works fine since I'm using integrated authentication), but how do I reference this user directly without having to pass it directly to my event? I don't want to have to pass this info through the pipeline because it really doesn't belong in the intermediate events/calls.

View 1 Replies

C# - Finding Session Alternative In Global Scope?

Feb 24, 2011

Quick question: Is there a "per-user" data storage object (similar to Session) that I can store data in the global scope (similar to HttpRuntime.Cache)? Almost as if Session and HttpRuntime.Cache had a baby.

Full Background: I have a ASP.NET website that was originally written for a single thread. Now I changed it so that certain actions will spawn a background thread and the browser polls a service to get status updates.

The problem I am having with this is that certain pieces of data are stored into the HttpContext.Session[] object (membership authentication token, for example). These pieces of data need to be unique to each user and accessible to the background thread. Session is not available to the background thread.

I am aware of HttpRuntime.Cache but that would require micromanagement to segment out the users and to expire it at the same time the session is expired. Session, on the other hand, automatically expires this things at the right times that I want it too and is already used by things like the SqlMembershipProvider.

My question is, is there something that behaves similar to the Session but exists in the global scope?

View 3 Replies

C# - Handling User Security Scope With NHibernate Or Other ORM?

Jun 5, 2010

How should one handle the situation where you may need to filter by a group of users.

Here is the scenario.

I have an administrator role in my company. I should be able to see all the data belonging to me plus all the other users who I have control over.

A plain old user however should only be able to access their own data.

If you are writing regular sql statements then you can have a security table with every user and who they have access too but i'm not sure how to handle this situation in the OO and ORM world.

Any one dealt with this scenario in a web application using an ORM?

View 1 Replies

C# - How To Create A Variable With Project-wide Scope

Feb 28, 2011

I want to declare a variable in such a way that I can access that particular variable and its value in all the asp pages in the project. Can anyone tell me how to declare a variable in C# such that it has project-wide scope?

View 8 Replies

C# - Events Through Application Scope To Multiple Clients?

Feb 15, 2011

First of all, I am creating a something like a client/server solution using a standard ASP.NET website - I do know this method is not adviced, and most people would love to scream "COMET!" or "HTML5 Sockets!" - but please don't ;-) !

What I am doing...

I am creating an MMORPG on a website.

I have several clients whom need to be in contact at the same time. This is done by a global object in the Application scope.

My problem

I need to invoke an event to several clients. For instance, when an attack has been performed, I need to update some graphics. The attack logic is resolved in the global object, but each of the clients has to respond to this.

Right now I do the following:

fightTrace.Reciever.InvokeMoveEnded(this);
fightTrace.FiredBy.InvokeMoveEnded(this);

(This is a kind of observer pattern)

What now happends is a race condition. The one who loads the page_load event will get both of these events, and the one who is not running them, will experience no changes in the UI.

So what is it I really want?

What I really need is some genuine and nice way to create an observer pattern through the application state. I need to send an event out to every "listener" which is in this case is a client, and then do some update.

View 1 Replies

Get An Error When Try To Load A Report Current Data Set Scope?

Sep 30, 2010

I always got the error below when i load my report.i cannot get it since i have already added the field on my data set.{"The Value expression for the textbox ‘textbox22’ refers to the field ‘isTransfer’. Report item expressions can only refer to fields within the current data set scope or, if inside an aggregate, the specified data set scope."}

View 7 Replies

C# - Initiate User Scope Class At Session Start?

Jun 16, 2010

I want to initiate a class for each user at the start of the user's session so that a single class can be used throughout the user's session. I checked out this post but I'm not sure where I should be placing this Sessionhandler class. Inside global.asax? How do I go about accomplishing this?

View 2 Replies

DataSource Controls :: Deadlock Transactions?

Feb 1, 2010

I have two databound controls on one page. GridView, DropDownList. My page is crashing with a SQL Transaction deadlock victim error. I would like to capture this error, and attempt to re-databind the controls. My first thought was to handle an event on the controls that allow me to do this, but I don't see which event to handle. I couldn't search any answers. Where should I begin?

View 3 Replies

ADO.NET :: Handling Back End Front End Both - Which Transactions Use?

Mar 17, 2011

I am a web developer handling back end frond end both.My question is that which transaction should I use
to maintain ACID. whether transactions in Sql Server or transaction in Ado.net?

View 4 Replies

Are There Any Transactions Around Multiple Webservice Calls

Mar 31, 2011

Are there any transactions around multiple webservice calls.Let me start with a commonly used example -- the travel agency. A customer intends to create a travel plan through an online travel agency. To do this, the online travel application calls the following three Web services:

-Air ticket booking
-Hotel reservation
-Taxi reservation

These three services are available from three separate vendors. If any one of these three services fails, the customer does not wish to proceed with the transaction (again, either all three services must succeed or none at all).My language programming is Asp.net c#.

View 1 Replies

Transactions Around Multiple Webservice Calls?

Apr 4, 2011

Are there any transactions around multiple webservice calls?but in ASP.net forum I got the answer below:

http://jalpesh.blogspot.com/2010/05/using-transactions-with-linq-to-sql.html it's offering system.transaction.

View 2 Replies

Databases :: Multiple Transactions In One Method?

Nov 10, 2010

I have an application which connect to oracle db.

I have two database hitting functions.

One is adding Userdetails(Fn Name : AddUserDtls) and another one adding address details(Fn name : AddAddresDtls) based on UserName which will get added after execution of first method ie AddUserDtls.

Problem I am facing is :

I have a single transaction and in that I have all the methods.

After the execution of first method,with out commiting i will go to second method.

and if any error occurs in second method.

I will rollback everything including the changes made by first method also.

Here one issue is there.

Since I am not committing the changes made by first method,

While I am executing the second method I am getting error that 'No user Name exists'

I understood that if we commit the transaction before the second method starts ,it will solve the issue.

But then it creates another problem.If some problem araise in the second method,then I cannot rollback the changes made by first method since it aleready commited.

View 1 Replies

ADO.NET :: Linq To SQL Transactions With Multiple Deletes?

Sep 29, 2010

I am trying to delete three related objects on one submit. Delete fails on one of the child objects, because of foreign key contraint with another table, It deletes one (the parent) but not the two child objects. All in one SubmitChanges(). I even used the TransactionScope, still same thing. So here is the scenario:

I have an object called Page which has a collection of objects called Webinars. There is another object Called Product which is one to one with Webinar.

[Code]....

View 5 Replies

Web Forms :: Creating Transactions In Database Using C#

Mar 24, 2011

i got an requirement where in the user submits the database scripts,stored procedures ,triggers ,functions or packages.i have create those in the database .if it throws an error it must be roll backed.how can i achieve this.

View 7 Replies

C# - Declaring Global Variable/class In Application Scope 3 Ways - Which One Is Best

Mar 3, 2010

I am looking for differences between those 3 ways of using static class in asp.net application scope.
Will all of these point to the same class?

Which one is preferable >object< defined declaratively inside global.asax or static class ?

examples:

<object runat="server" scope="application" class="classname" ID="objID"></object>

VS

public static class classname {}

VS

Application("a") = new classname();

View 1 Replies

DataSource Controls :: Use Scope Identity To Get Newly Inserted Table

Feb 14, 2010

I have an SQL Server table named "Fields" with an autoincrement identity column "FieldID" as the primary key, an nchar column "Phrase" that textbox entries are to be stored in from a web page, and another column that is defaulted to null. The following is the recommended example on how to use Scope_Identity() to get a newly inserted table row identity value:

//C#
string query = "Insert Into Categories (CategoryName) Values (@CategoryName);" +
"Select Scope_Identity()";
int ID;
string connect = @"Server=.SQLExpress;AttachDbFilename=|DataDirectory|Northwind.mdf;" +
"Database=Northwind;Trusted_Connection=Yes;";
using (SqlConnection conn = new SqlConnection(connect))
{
using (SqlCommand cmd = new SqlCommand(query, conn))
{
cmd.Parameters.AddWithValue("@CategoryName", Category.Text);
conn.Open();
ID = (int)cmd.ExecuteScalar();
}
}

Obviously, this example uses a Categories Table in a Northwind database, which I do not have. So I am confused by how to adapt this example for my application. The following is my data context:

DataClassesDataContext db = new DataClassesDataContext();

Could you explain how I can adapt the example for my "Fields" table in my "EFMDB" database?

View 13 Replies

C# - When Implementing The Singleton Pattern In A Web Application The Static Variable Scope?

Jan 25, 2010

want to make sure I am not assuming something foolish here, when implementing the singleton pattern in an ASP .Net web application the static variable scope is only for the current user session, right? If a second user is accessing the site it is a different memory scope...?

View 4 Replies

C# - Enforce Transactions For Write Operations In SQL Server?

Nov 16, 2010

How do I ensure and enforce that all write operations to my MS SQL Server DB are transactions-based?

The reason I want to do this is that the DB contains financial account data and operations that fail halfway through some set of changes should not be able to mess up the database by mistake or by crashing.

The application is written in ASP.NET C#.

Edit:

There is a DAL but it does not (yet) require transactions for changes.We wrote the DAL ourselves. We did not use ORM.

I know how to perform one transaction from ASP.NET.

I want to ensure that all changes are made in transaction form so that if the application throws some exception in the middle, there will be no change to the database.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved