SqlTransaction Rollback

Apr 4, 2007

Hello,



I want to know, if you can use SqlTransaction even if you only execute one statement/query? I am particularly interested in Rollback(), which is called when the user presses the cancel button to abort a long file transfer.

Does rollback immediatley cancel the transfer and return control? Or, what is the best way of implementing a cancel option for transferring data?



Thank you

View 5 Replies


ADVERTISEMENT

About SqlTransaction

Nov 6, 2003

updatestring = "Update [Flow] set received=1 where flowid=@flowid"
insertstring = "Insert into [Flow] (barcode, copyid, floworder, recvdate, recvuser, recvdepartment) "
insertstring += "values (@barcode, @copyid, @floworder, @recvdate, @recvuser, @recvdepartment)"

is it can't use sqltransaction in the same table ???

when i not apply the sqltransaction, then the about two queries can work success, but when i apply the sqltransaction, then have an error in following.

error :
Object reference not set to an instance of an object

Source Error:

Line 278: message.Text = "Recebido o documento " & barcodetx.Text & "!!"
Line 279: Catch ex As Exception
<red>Line 280: objtransaction.Rollback()</red>
Line 281: message.Text = "Não se conseguiu registar!!"
Line 282: Finally

View 1 Replies View Related

The SqlTransaction

Apr 4, 2006

Hi,
I am getting this error message
"This SqlTransaction has completed; it is no longer usable"
What's really strange is that I am getting this error from a page where I am not even using SqlTransaction.
How can I find the root cause and solve this problem?
Help Please!

View 4 Replies View Related

Is SqlTransaction Overhead ?

Oct 16, 2007

hi,Is it over head to use SqlTransaction(begin, commit, rollback) for a single transaction.am not using application  block or enterprise library.only a single insert statement.       

View 3 Replies View Related

SqlTransaction Error Help

Mar 15, 2006

Hi,
I use  SqlTransaction to add record to the database. But I got a warning message on the "objTransact.Rollback()"  that said "Variable 'objTransact' is used before it has been assigned a value, A null reference exception could result at runtime".  what does this mean? how can I fix it? The following  is the code. Thanks.
---------------------------------------------------------------------------------
Dim objTransact As SqlTransaction
Try

objConnect.Open()

objTransact = objConnect.BeginTransaction()
cmd.Connection = objConnect
cmd.Transaction = objTransact
-----do some sql query here............
objTransact.Commit()


Catch objError As Exception


objTransact.Rollback()
Finally

objConnect.Close()


End Try

View 6 Replies View Related

SqlTransaction Error.

Oct 17, 2007

Hi,

I am getting the below error when using the SqlTransaction's for doing DML operations for different tables,

"System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding."


Thanks in advance.

With regards,
Mani

View 5 Replies View Related

Using SqlTransaction Object Across Functions

Jun 27, 2006

I have a class which has connection, transaction object and BeginTransaction of that method opens the transaction. This class has an array of objects of a base class which refers to their derived classes at runtime and passes the reference of connection and transaction object to the derived class. Now from the main class I call BeginTransaction and then from any of the array element some insert update will be called using the same connection and transaction which has been opened from parent class.
I get the following exception while executing the sql statement in the method of derived class
Unhandled Exception: System.InvalidOperationException: ExecuteNonQuery requiresthe 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.   at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)   at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
 
 
 I tried using isolation level but transaction control does not work. I can not change the design...

View 3 Replies View Related

C# SQLTransaction Or SQL BEGIN TRANSACTION

Dec 31, 2007

I want to know if it's a good practice to use sql-transaction in both c# and sql procedures code.

View 4 Replies View Related

SQLTransaction Locking Up Table

Jul 23, 2005

Hi All,I am using a SQLTransaction to insert records into a table. At onetime, there are 5000 or more records to be inserted one by one. Ittakes some 20-25 mins for the entire process to run.Another application accesses the same table.As long as the insert process within the transaction isn't completed,the second application is not getting any response from the server. Ieven tried to run a SELECT on the table in SQL Query Analyzer while theinsert process was running and it also did not respond till the timethe insert process finished!Is this normal that a transaction is locking up a table? How do Iovercome it? I am using IsolationLevel.ReadUncommitted for thetransaction.If I do not run the process within a SQLTransaction, the second processor running the SELECT in Query Analyzer does not hang.Thanks,Sanjeev Mahajan

View 3 Replies View Related

SqlTransaction's And Auto Increment Fields

Mar 13, 2007

Hi,
So I'm having an issue with a SqlTransaction and retrieving the auto-increment ID after an insert.  Presumably this is because I have to commit the transaction before the ID's are generated, but I need the ID's before I commit the transaction (because their is another part of the transaction that requires them).
 Is there any way to get these id's other than maybe getting the Max(ID) and auto-incrementing them myself in code to what they will be when the transaction is committed.  If this is the best way how do I ensure no other connections can insert stuff while this transaction is going on?
 Or is there a better way to do this whole thing? (i don't know really know how to do stored procedures, and presumably this would be the best way, but is there a good way to do it not Stored Procedures)
Thanks!

View 2 Replies View Related

Error Explaination SqlTransaction Has Completed

Apr 4, 2008

can anyone tell me what is the origin of this error "This SqlTransaction has completed; it is no longer usable".

View 2 Replies View Related

Using An Open SQLTransaction In Order To Lock A Record...

Jun 2, 2005

Hello,I am trying to begin a transaction is ASP.NET that acts as a temporary lock on a record so that another web user can not gain access to that row of information.  My problem is that when I begin the transaction, if the user then closes out of the browser completely, the temporary lock that is put on my table from the transaction does not go away.  Further, I have no idea if it will or if there is a time range you can specifiy to do so.What I am wondering is if anyone has ever tried this before, or does anyone have a definite answer to the following question, "If I begin a transaction, and then I do NOT rollback or committ that transaction, will it ever rollback on its own and if so where can I set this time frame?"Thanks in advance for any help.

View 3 Replies View Related

Does It Locks Database/tables When Only Select Query Comes In SQLTransaction

Jul 12, 2006

Hi,

I want to make SQLTransaction as global and use it checking the State.
But then where there are Only Select queries are going to fire, it will open transaction.

So, Does it locks database/tables when Only Select query comes in SQLTransaction.

If you have another successful way of doing this, Please suggest.

Thanking you.

tats

View 8 Replies View Related

How To Rollback SQL

Aug 12, 2007

Hello experts, I made a huge mistake on a production server, ran an update without the WHERE clause. UPDATE myTableSET Field1 = 'SOmetext',Field2 = 'sometext2'Is there a way to rollback? I read something a while ago about transaction logs.SOS!Thanks 

View 4 Replies View Related

Rollback

Sep 27, 2007

HI,
 Suppose I execute any transaction say inserted some rows.
I want  to delete my previous transaction using rollback.
What is the proper syntax for that.
In Query Window:
Insert ---------- executed
rollback.
it was asking for name of the transaction. How to give that.
Help me out
Thanks
Bye
 
 
 

View 1 Replies View Related

Why Not Rollback?

Nov 12, 2003

This is my stored procedure. Problem is that a rollback does not happen when there is an error ? How can this be, am starting and ending the transaction?

CREATE Procedure opretKunde
(
@cvr int,
@url varchar(200),
@firmaNavn varchar(50),
@adresse varchar(150),
@postnr int,
@fax int,
@tlf int,
@email varchar(200),
@bruger varchar(20),
@kode varchar(32)
)
AS

BEGIN TRANSACTION

INSERT INTO login
(
brugernavn,
kodeord,
type
)
VALUES
(
@bruger,
@kode,
'k'
)

INSERT INTO kunde
(
cvr,
url,
navn,
fax,
tlf,
email,
brugernavn
)

VALUES
(
@cvr,
@url,
@firmaNavn,
@fax,
@tlf,
@email,
@bruger
)

INSERT INTO adresse
(

type,
cvr,
adresse,
postnr
)
VALUES
(

'b',
@cvr,
@adresse,
@postnr
)

COMMIT

GO

View 1 Replies View Related

Rollback

Aug 10, 2000

Hi,

Can I rollback a database if I have transaction logs?

For example, I want to rollback the database without all the transactions that occurs within the last 10 days.

Thank you.

View 3 Replies View Related

Rollback

May 18, 2000

I tried killing a rollback several times, but it would not disapear.
I came back the next day, it is still there.

Anyone knows how to get rid of a rollback?

Thanks in advance.

View 2 Replies View Related

Rollback

May 5, 2000

Hi:

I have rollback on one of the users. I tried killing
her process through Enterprise Manager and Query Analyzer,
but I still can see her process on the screen. However, her
login is grayed out after I execute the kill query.

I have encountered this problem several times, and the only way
I can get clear the rollback is by rebooting the server.

Does anyone have a sugeestion on how to clear the rollback
without rebooting.

Please advise if you have any suggestion.

Thanks in advance.

View 2 Replies View Related

DTS ROLLBACK

Apr 5, 2000

Hi All
A question on DTS ROLLBACK CAPABILITY.
Is it possible to setup a DTS pkg to roll back the loaded files if a step fails?
If a step fail records inserted by Data Pump to a table should be removed.
Is this possible? If so how can we achieve this?

Any advice is appreciated.

Thanks

View 5 Replies View Related

Rollback

Dec 10, 2003

when i give rollback in my QA it gives an error saying (something like this)
- no begin transaction specified

In oracle it works fine why?

View 6 Replies View Related

Rollback

Jan 15, 2004

how to rollback(undo) record was i deleted???

pls tell me...

View 1 Replies View Related

Rollback

May 22, 2004

Hello every body,
I would like to know the procedure, that how to rollback my transaction in sql server 2000

View 5 Replies View Related

ROLLBACK

Jun 29, 2006

Hi,

i wanna know something, i inserted some rows of data to a table, but i wanna undo those insertion. How can i do it?

thanks

View 9 Replies View Related

Is Rollback Possible?

Aug 29, 2006

hi friends,

is it possible to roll back a transaction here? i heard that it will be possible only if we wrote the code only in certain block.please tell me the block.


vinod

View 5 Replies View Related

Rollback

Oct 17, 2007

The code inserts into table TABLES. TABLES has a primary key.
If the insert statement has no error it should insert 'ROWS INSERTED' to table CONTROL and update table DATETRACKING else insert 'ROWS NOT INSERTED' to table CONTROL and do not update table DATETRACKING.
1- I will like to improve my code if it is possible.
2- Can I use a rollback?

DECLARE @ROWCOUNT INT
DECLARE @ERROR INT
DECLARE @LASTDT DATETIME

SET @LASTDT =GETDATE()
BEGIN TRAN
insert tables
select 4

SELECT @ROWCOUNT = @@ROWCOUNT, @ERROR = @@ERROR
IF (@ERROR <> 0)
BEGIN
INSERT CONTROL
SELECT 'ROWS NOT INSERTED', @ROWCOUNT
END
ELSE
BEGIN
INSERT CONTROL
SELECT 'ROWS INSERTED', @ROWCOUNT
END
COMMIT TRAN

IF (@ROWCOUNT > 0)
BEGIN
UPDATE DATETRACKING
SET LASTDATEDL = GETDATE()
END




http://www.sqlserverstudy.com

View 4 Replies View Related

Rollback

Jan 28, 2008

Hi All,

Can anyone please tell how to rollback a transaction or a command.

TIA

RKNAIR

View 1 Replies View Related

Rollback SP4

May 12, 2008



Hi all

I have SQL server 2000 with SP4,
1.Some of the reason,I want roll back SP4 and I want replace SP3.
2.Is it true SP4 slow down the Quey performance compare with SP3.

any suggestion appreciated.

View 1 Replies View Related

My Rollback Does Not Work

May 30, 2007

My rollback does not work
In my SP I want any of cmdS,cmdS2,cmdS3,cmdS4 produces error Rollback must be executed for all of cmdS,cmdS2,cmdS3,cmdS4 . I tested for error producing situation but no rollbak occured.
How can I solve this problem. Thanks.
Below is my SP .
..........
..........
.......... 
begin transaction
..........
..........If Len(ltrim(rtrim(@cmdS)))>0
execute(@cmdS)
 If Len(ltrim(rtrim(@cmdS2)))>0
execute(@cmdS2) If Len(ltrim(rtrim(@cmdS3)))>0
execute(@cmdS3)
 If Len(ltrim(rtrim(@cmdS4)))>0
execute(@cmdS4)
If Len(ltrim(rtrim(@cmdS)))>0 or Len(ltrim(rtrim(@cmdS2)))>0 or Len(ltrim(rtrim(@cmdS3)))>0 or Len(ltrim(rtrim(@cmdS4)))>0
Beginif @@ERROR <>0
begin
rollback transaction
set @Hata = 'Error !'
end
Else
Beginset @Hata = 'Sucessfully executed :)' End
End
commit transaction
RETURN
 
 

View 1 Replies View Related

What To Do After A Transaction Rollback?

Dec 9, 2003

Hi!

I just made a transaction which writes and reads some data from a database as one unit. Now, I would like to know, what happens, if this transaction does not commit, but instead performs a rollback? Should I use a boolean loop which keeps on trying the transaction until it commits or is there an alternative? I would appreciate any suggestions or help!

Thanks!
Timothy

View 1 Replies View Related

Timeout On Rollback

May 17, 2004

I keep getting timeout expired when trying to rollback a transaction (have not tried to commit yet). The script hangs for around 30 secs, then fails.

Now, i've seen there's a command timeout for sqlcommands which defaults to 30 secs, but cannot find anything similar for sqltransaction...

Anyone can help?

Thanks. -julio

View 3 Replies View Related

SQL Transactions RollBack...

Dec 17, 2004

Hello:

I am just starting to falmiliarize myself with SQL transactions... I just created an SQL transaction... The first statement gets a value, if the value equals "" then the second statement executes... So if the value <> "" Then the second statement wont execute... What would happen in this scenario if the .Rollback is triggered? Heres my code:

Try
conSqlConnect.Open()
objTransaction = conSqlConnect.BeginTransaction
cmdSelect.Transaction = objTransaction
cmdInsert.Transaction = objTransaction
dtrdatareader = cmdSelect.ExecuteReader()
While dtrdatareader.Read()
varCheckNumber1 = dtrdatareader("Status")
End While
dtrdatareader.Close()
If varCheckNumber1 = "" Then
cmdInsert.ExecuteNonQuery()
End If
objTransaction.Commit
Catch
objTransaction.RollBack
Return "00"
Finally
If conSQLConnect.State = ConnectionState.Open Then
conSqlConnect.Close()
End If
End Try


Any Ideas?

View 5 Replies View Related

Rollback Issue

Mar 30, 2001

Hello list,

I've some problem in SQL Server 7.0 and hope some one out there will help me with it. The problem is as follows:

When I view a proces in the process info screen, I see one process says "Rollback" in the status window and the spid is greyed out like a system process. In the command window it says, Select and wait type is "Exchange". This is taking too much cpu cycles and causing much of the server to perform very slow.

I tried to kill this session from the ISQL and Enterprise manager, But to still see this process running on with out getting killed. Also this process keeps coming.

Please advice me how to get rid of this and why is it ocurring again and again.

Thanks in advance.

Khan

View 2 Replies View Related







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