ADO.NET :: Transaction Is Not Working Using SqlTransaction Class?

Sep 23, 2010

Here is my code:

[Code]....

The problem is that the transaction is not working.For instance,now the code is correct so both sql statements are getting executed.However,yesterday the 'update' statement was incorrect but I could not realise that IT WAS NOT ALRIGHT, because the function was not throwing myTrans.Rollback().I had put a breakpoint and there was no rollback.Apparently, now the sql statements,above,are ok,so there is no issue at the moment,however if there was an error,still the function would execute as if the sql statements were successful.

I know that I can use a Stored procedure and finish with it.But i want to see it how the Transaction works using SQLtransaction class.

View 2 Replies


Similar Messages:

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

SQL Server :: This SqlTransaction Has Completed - It Is No Longer Usable

Jul 16, 2010

Normallt I would put the rollback in the catch, but I want to make sure it worked. I got "This SqlTransaction has completed; it is no longer usable."

[Code]....

View 7 Replies

SQL Server :: SqlTransaction.BeginTransaction IsolationLevel Locking?

Oct 2, 2010

i have a web application who uses a stored proc in our SQL Database and process the data with SqlTransaction.BeginTransaction. but we don't place any isolation level.

The stored proc have multiple processing like insert, update and large queries from multiple tables. we decided to place the SqlTransaction class in our code to access the commit and rollback method incase the stored proc has an error.

later when the user is using our website, they experience locking, by the way the average number of users are around 600 a day.

is it possible to eliminate the chance of locking when using the SqlTransaction class when we use an isolation level like "Snapshot".

if not, what level should we use.

[Code]....

View 1 Replies

Web Forms :: This SqlTransaction Has Completed - It Is No Longer Usable

May 7, 2015

When I insert data to multiple table  record inserted successfully . But exception occur .

as "

This SqlTransaction has completed; it is no longer usable

My code is as bellow

"
string sqlMsg = string.Empty;
SqlTransaction trns = null;
try
{
using (con = new SqlConnection(clsConnection.GetSqlConnection()))
{
clsConnection.OpenSqlConnection(con);
trns = con.BeginTransaction(IsolationLevel.ReadCommitted);

[Code] ....

View 1 Replies

Web Forms :: Profile Class Not Working?

Sep 10, 2010

1) I am making use of Profile class in my application, and using System.Web namespace, but intellisense is not able to recognize it. But when I make use of System.Web.Profile, it is working properly. What is the reason of this?

2) System.Web.Profile is not able to recognize IsAnonymous property, why is it not recognizing?

View 2 Replies

Update Using Objectdatasource Via Class And Dataset Not Working?

Jul 22, 2010

i try to update the gridview i keep on getting the error like objectdatasource could not find a non generic method 'update' which has parameters a,b,c etc.i have done everything right but i cant seem to figure this one out.i am using objectdatasource,a class file and a dataset.xsd file.

[code]...

View 2 Replies

MVC :: Entity Framework Class - DisplayFormat Not Working

Nov 2, 2010

I have a simple entity framework class called "NewsItem" which has 3 properties: Id, PostDate and DescriptionText. To format the postdate property I created a partial class as the following:

[Code]....

This seems to be the way Microsoft has outlined doing it in this link: [URL] It seems as thought he partial class isn't being "picked up" in relation to my entity object as none of the formatting I've tried has done anything. Any ideas on what I've done wrong or might have missed?

View 3 Replies

Web Forms :: Setting Properties Within BasePage Class Not Working?

Jan 11, 2010

We are trying to use a BasePage class (which inherits from Page) to populate and set the Meta Keywords and Meta Description Tags. I am using masterpages and below is an example code extract... According to examples on the internet, I could then set this also via the Page Directive using the MetaKeywords and MetaDescription properties, but they do not appear.

I have tried setting the CodeFileBaseClass="MyNamespace.UI.BasePage" but this does not work either. Using debug I can see that the BasePage classes' MetaKeywords and MetaDescription properties are not being set within my content page. I can access the properties but not set them.

== BASEPAGE CLASS ==

[Code]....

== PAGE CLASS ==

[Code]....

View 3 Replies

Data Annotation Attributes Not Working Using Buddy Class Metadata In An MVC App?

Oct 7, 2010

I have found hints that MVC 2 recognises the 'buddy class' type of property metadata, where data annotation attributes are applied to a 'buddy' metadata class, and the MetadataType on the actual entity class points to that buddy class, as below. However, as below, it seems the only attribute that makes any difference to the rendered UI is DisplayName. Why are the other attributes like DataType, Required, and ReadOnly not working? I.e. why can I enter text in a read only field? Why do I not get an error when a required field is empty? Why does the DataType attribute have no apparent effect? Why does EditorForModel not include validation messages?

[MetadataType(typeof(CustomerMetadata))]
public partial class Customer
{
public class CustomerMetadata
{
[ScaffoldColumn(false)]
public object CustomerId { get; set; }
[DisplayName("CustomerNo.")]
[ReadOnly(true)]
[Required(AllowEmptyStrings = false, ErrorMessage = "Customer No. is required.")]
public object CustomerNo { get; set; }
}
}

I find behaviour the same whether I use an explicit LabelFor and TextBoxFor for each model property, or a single EditorForModel for the whole model.

View 2 Replies

Web Forms :: Impact Of Command Timeout Property While Working With Command Class

Jun 3, 2013

I am working with odbcCommand class, in one case I got error that QueryTimeout Expired. Even though this SP is taking only 3-4 secs in DB to execute these specific values, When I set the CommandTimeout=0, then it worked fine.

1)Is it necessary to always use this property while working with Command Class.

2)If it is not suggested to use, but still if I use it then how it will impact the performance.

Below is my code sample.

OdbcConnection conObj;
OdbcCommand cmdObj;
OdbcDataAdapter daObj = new OdbcDataAdapter();
public DataTable GetIFAContractNoteData(string RecipientIDIFACN, DateTime BatchDateIFACN, int TransmittalReportIDIFACN) {
conObj = new OdbcConnection(GlobalVariables.strDsnName + ";" + GlobalVariables.strDsnDataBase + ";" + GlobalVariables.strDsnUserID + ";" + GlobalVariables.strDsnPassword);

[code]....

View 1 Replies

ADO.NET :: How To Check SQL Transaction Log

Jan 7, 2011

We can catch the error log information by use EXEC xp_readerrorlog. I am just wondering is SQL have other types of log for us to reference information

I didn't wrote trigger for my tables... one table was missing, would it possible to know when the table was be deleted by some kind of transaction log?

View 6 Replies

C# - How To Format A Transaction Id

Feb 25, 2010

What is the best way to format a transaction id?Conditions Max 15 characters: XXXXXXXXXXXXXXX -All transaction must be unique -Can contain both numerical and alphabetical characters -May contain Year, month, day

View 1 Replies

Transaction & Disconnected Mode

Jan 2, 2010

disconnected mode and transaction.it's give to me ERROR message

Quote.ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized
PHP Code:
da.InsertCommand = cb.GetInsertCommand

my code is:

PHP Code:
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("DBCon").ConnectionString)
Dim cmd As New SqlCommand("insert into Customer (customer_id, customer_name, note) values (@cid, @cname, @note)", con)
Dim da As New SqlDataAdapter("select * from CustomerPhone", con)

| [code]....

View 7 Replies

Commit Transaction In SQL Server

Dec 10, 2010

table 1
[Code]....
Table 2
[Code]....
my stored procedure
[Code]....

when ever i m passing the wrong the value in second table while updating its not updating the table but the problem it is inserting the value in first table i want the whole trans should proceed if success if not rollback

View 2 Replies

SQL Server :: How To Check Transaction Log

Sep 23, 2010

I know these 2 commands

sp_who and sp_who2 → knowing who are updateing

DBCC log (DB_NAME,4) → I can't really understand these information..

just wondering does there exists a log file, so we can check who have updated database from it?

View 3 Replies

ADO.NET :: Save Log On Uncomplete Transaction

Feb 16, 2011

I want to know is there any method or any concept to save transactions before system crash or failure. I am doing project in C# and backend is sql server 2005.

View 1 Replies

ADO.NET :: TransactionScope And Explicit Transaction In It

Feb 23, 2011

[Code]....

Now,

1. If In transaction scope if 1st Transaction is commited, buting 2nd one exception occurs and it is rolled back

2. Any other exception occurs, after 1st transaction is completed/commited

Here, explicit transactions are used. In both cases does all transactions in the scope are revert back? What are the possiblities here?

View 7 Replies

ADO.NET :: Entity Framework Transaction?

Feb 2, 2011

i'm using the entity data model to insert data to my database. the thing is that when inserting data to more than one table i want to ensure that all actions completed correctly(or catch an exeption if not).

View 1 Replies

C# - How To Generate A Transaction Number

Dec 9, 2010

I was thinking of formatting it like this

TYYYYMMDDNNNNNNNNNNX
(1 character + 19 digits)

Where

T is type
YYYY is year
MM is month
DD is day
N is sequencial number
X is check digit

The problem is, how do I generate the sequencial number? since my primary key is not an auto increment integer value, if it was i would use that, but its not.

EDIT can I have the sequencial number resets itself after 1 day (24hours).

P201012080000000001X <-- first
transaction of 2010/12/08
P2010120810000000002X <--- second
transaction of 2010/12/08
P201012090000000001X <--- First
transaction of 2010/12/09
(X is the check digit)

View 6 Replies

NHibernate Transaction Management In .NET MVC ?

Apr 5, 2010

I am writing a simple ASP.NET MVC using session per request and transaction per request patterns (custom HttpModule).It seems to work properly, but.. the performance is terrible (a simple page loads ~7 seconds). For every http request, graphical resources incuding (all images on the site) a transaction is created and that seems to delay the loading times (without the transactions loading times per one image are ~1-10 ms with transactions they are over 1 second).What is the proper way to manage transactions in ASP.NET MVC + NH stack?

When i've put all transactions into my repository methods, for some obscure reasons I got 'implicit transactions' warning in NHProf (the SQL statements were executed outside transaction, even that in code session.Save()/Update()/etc methods were invoked within transaction 'using' scope and before transaction.Commit() call) BTW are implicit transactions really bad?

View 3 Replies

DataSource Controls :: Transaction Is Not Getting Rollback?

Mar 15, 2010

I have written several queries under one single transaction. When any of the query throws an error then the whole transaction should rollback. However, in some rare cases say 2% cases even after the error the next transaction is getting comitted.

note that all transaction processes (opening, committing and rollback) is done through .net.

I am using 64bit windows 2003 for data and application server. And website is configured for runapp32on64.

View 6 Replies

ADO.NET :: Linq To Sql Many To Many Insert Into Database In One Transaction

Mar 27, 2011

i have a Tag Table TagId TagName

Post Table PostId PostName

TagPost Table TagId PostId

How can i do a many to many insert into database in one transaction?

View 4 Replies

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

What Is Digest Authentication / Finding Example Of The Transaction

Mar 5, 2010

i searched on google for a simple explanation of digest authentication but didn't find any good ones. How does it differ from Basic Authentication other than sending credentials as plain text?

give an example of the transaction.

View 2 Replies







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