Board index » delphi » Re: Transactions

Re: Transactions


2004-08-07 02:11:45 AM
delphi62
It's odd because my connection is not in transaction. And yes I am using
SQL Server 2000.
and I just have one line like
Connection.SQLConnection1.StartTransaction(TD);
it bombs
if I have change it to
if not Connection.SQLConnection1.InTransaction then
Connection.SQLConnection1.StartTransaction(TD);
Now remember when debugging I get this value from
Connection.SQLConnection1.InTransaction=FALSE
I think that explained it better let me know if you need more info.
"Bill Todd (TeamB)" <XXXX@XXXXX.COM>writes
Quote
On Fri, 6 Aug 2004 13:02:56 -0500, "Ryan Schoolman"
<XXXX@XXXXX.COM>writes:

>I added this to my code. Even when InTrasaction=false and then
executes
>the next line "StartTransaction" I don't get the error. That is a weird
>problem.
>
>if not Connection.SQLConnection1.InTransaction then
>Connection.SQLConnection1.StartTransaction(TD);

What is odd about that? That is exactly the way it should work. If you
are not in a transaction you can start one with no error.

Are you using SQL Server?

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
 
 

Re: Transactions

That seemed to clear up the problem
"Ryan Schoolman" <XXXX@XXXXX.COM>writes
Quote
It's odd because my connection is not in transaction. And yes I am using
SQL Server 2000.
and I just have one line like
Connection.SQLConnection1.StartTransaction(TD);
it bombs
if I have change it to
if not Connection.SQLConnection1.InTransaction then
Connection.SQLConnection1.StartTransaction(TD);

Now remember when debugging I get this value from
Connection.SQLConnection1.InTransaction=FALSE

I think that explained it better let me know if you need more info.



"Bill Todd (TeamB)" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...
>On Fri, 6 Aug 2004 13:02:56 -0500, "Ryan Schoolman"
><XXXX@XXXXX.COM>writes:
>
>>I added this to my code. Even when InTrasaction=false and then
executes
>>the next line "StartTransaction" I don't get the error. That is a
weird
>>problem.
>>
>>if not Connection.SQLConnection1.InTransaction then
>>Connection.SQLConnection1.StartTransaction(TD);
>
>What is odd about that? That is exactly the way it should work. If you
>are not in a transaction you can start one with no error.
>
>Are you using SQL Server?
>
>--
>Bill (TeamB)
>(TeamB cannot respond to questions received via email)


 

Re: Transactions

Still having the same problem. I did a complete build of the project. And
then it started happening again.
"Ryan Schoolman" <XXXX@XXXXX.COM>writes
Quote
That seemed to clear up the problem



"Ryan Schoolman" <XXXX@XXXXX.COM>writes
news:4113c907$XXXX@XXXXX.COM...
>It's odd because my connection is not in transaction. And yes I am
using
>SQL Server 2000.
>and I just have one line like
>Connection.SQLConnection1.StartTransaction(TD);
>it bombs
>if I have change it to
>if not Connection.SQLConnection1.InTransaction then
>Connection.SQLConnection1.StartTransaction(TD);
>
>Now remember when debugging I get this value from
>Connection.SQLConnection1.InTransaction=FALSE
>
>I think that explained it better let me know if you need more info.
>
>
>
>"Bill Todd (TeamB)" <XXXX@XXXXX.COM>writes
>news:XXXX@XXXXX.COM...
>>On Fri, 6 Aug 2004 13:02:56 -0500, "Ryan Schoolman"
>><XXXX@XXXXX.COM>writes:
>>
>>>I added this to my code. Even when InTrasaction=false and then
>executes
>>>the next line "StartTransaction" I don't get the error. That is a
weird
>>>problem.
>>>
>>>if not Connection.SQLConnection1.InTransaction then
>>>Connection.SQLConnection1.StartTransaction(TD);
>>
>>What is odd about that? That is exactly the way it should work. If you
>>are not in a transaction you can start one with no error.
>>
>>Are you using SQL Server?
>>
>>--
>>Bill (TeamB)
>>(TeamB cannot respond to questions received via email)
>
>


 

Re: Transactions

Ryan Schoolman writes:
Quote
It's odd because my connection is not in transaction. And yes I am
using SQL Server 2000.
and I just have one line like
Connection.SQLConnection1.StartTransaction(TD);
it bombs
if I have change it to
if not Connection.SQLConnection1.InTransaction then
Connection.SQLConnection1.StartTransaction(TD);

Now remember when debugging I get this value from
Connection.SQLConnection1.InTransaction=FALSE
Where exactly is this code? It sounds to me like the code is getting called
more than once, so the connect works the first time and fails thereafter.
That would explain why checking InTransaction solves the problem.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: www.logicfundamentals.com/RADBooks.html
In a tornado, even turkeys can fly. - unknown
 

Re: Transactions

I have not solved this problem if someone has an idea please reply.
"Wayne Niddery [TeamB]" <XXXX@XXXXX.COM>writes
Quote
Ryan Schoolman writes:
>It's odd because my connection is not in transaction. And yes I am
>using SQL Server 2000.
>and I just have one line like
>Connection.SQLConnection1.StartTransaction(TD);
>it bombs
>if I have change it to
>if not Connection.SQLConnection1.InTransaction then
>Connection.SQLConnection1.StartTransaction(TD);
>
>Now remember when debugging I get this value from
>Connection.SQLConnection1.InTransaction=FALSE

Where exactly is this code? It sounds to me like the code is getting
called
more than once, so the connect works the first time and fails thereafter.
That would explain why checking InTransaction solves the problem.

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: www.logicfundamentals.com/RADBooks.html
In a tornado, even turkeys can fly. - unknown


 

Re: Transactions

Ryan,
I have a problem like this, but it is solved. The variable TD was defined
twice, so i define
it as global variable.
(sorry for my english)
(Eu tive um problema semelhante, mas consegui resolver. A variável TD estava
definida em
mais de um local, sendo assim eu eliminei as instancias locais da variável e
a defini como pública. O banco que utilizo ?Oracle).
Ricardo Carmo.
"Ryan Schoolman" <XXXX@XXXXX.COM>escreveu na mensagem
Quote
I have not solved this problem if someone has an idea please reply.


"Wayne Niddery [TeamB]" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...
>Ryan Schoolman writes:
>>It's odd because my connection is not in transaction. And yes I am
>>using SQL Server 2000.
>>and I just have one line like
>>Connection.SQLConnection1.StartTransaction(TD);
>>it bombs
>>if I have change it to
>>if not Connection.SQLConnection1.InTransaction then
>>Connection.SQLConnection1.StartTransaction(TD);
>>
>>Now remember when debugging I get this value from
>>Connection.SQLConnection1.InTransaction=FALSE
>
>Where exactly is this code? It sounds to me like the code is getting
called
>more than once, so the connect works the first time and fails
thereafter.
>That would explain why checking InTransaction solves the problem.
>
>--
>Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
>RADBooks: www.logicfundamentals.com/RADBooks.html
>In a tornado, even turkeys can fly. - unknown
>
>


 

Re: Transactions

I have three tables that must be updated at once. The code I am using is
basically
procedure
var
TD: TTransactionDesc;
begin
TD.TransactionID := 1;
TD.IsolationLevel := xilREADCOMMITTED;
SQLConnection1.StartTransaction(TD);
try
with Qry1 do begin
(set params...)
ExecSQL;
end;
with Qry2 do begin
(set params...)
ExecSQL;
end;
with Qry3 do begin
(set params...)
ExecSQL;
end;
SQLConnection1.Commit(TD);
except
SQLConnection1.RollBack(TD);
end;
However, if there is an error in Qry3, then Qry1 and Qry2 do not get rolled
back.
Maybe I have missed something. Should this code work?
Thanks.
 

Re: Transactions

My initial post missed out that I am using MySQL (version 4.0.20a), but I
can clarify the problem.
With some code basically as follows:
TD.TransactionID := 1;
TD.IsolationLevel := xilREADCOMMITTED;
SQLConnection1.StartTransaction(TD);
Input1Qry.ExecSQL;
Input2Qry.ExecSQL;
Input3Qry.ExecSQL;
SQLConnection1.RollBack(TD);
only the first operation (Input1Qry.ExecSQL;) is rolled back. The other two
are processed even though I have not called Commit.
Can anyone tell me why? Thanks.
 

Re: Transactions

Hi,
i am using bcb5 and bde with paradox tables. Local share is set to TRUE. I face the following problem:
When i execute DB->StartTransaction() in my application an execption is raised (translated from german):
Message: 'The folder is controlled by another .NET-file.'
Folder: C:\
File: D:\...\PDOXUSRS.LCK.
I found out that this execption is not raised when I set local share to false.
The exception does not occur eighter on another PC which is a stand alone PC and has local share set to true.
How can this problem be solved?
Thanks for your help
Andreas
 

Re: Transactions

Delete *.LCK from the directory that contains the Paradox tables and see
if that solves the problem.
Is this a multi-user application?
--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
 

Re: Transactions

Well there are no *.LCK files in the directory that contains the tables.
These files are created automatically when I start my application and are
deleted when I close my application (Local share = true).
Two apps share this db-directory on a local PC. So I need to set local share to true.
Any other hints?
Thanks
Andreas
"Bill Todd" <XXXX@XXXXX.COM>writes:
Quote
Delete *.LCK from the directory that contains the Paradox tables and see
if that solves the problem.

Is this a multi-user application?

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
 

Re: Transactions

If there are no old lock files then one or more of the machines that
access the tables has a different NetDir path set in the BDE
Administrator. All of the workstations must use exactly the same NetDir
path with one exception. If the machine that hosts the tables is also used
as a workstation the NetDir path on that machine can use a local drive
letter instead of a mapped drive letter as long as the rest of the path is
the same. One good solution is to use the same UNC path on all of the
machines.
--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
 

Re: Transactions

I use only one PC (not a network). There are two apps sharing one database installed on this PC.
The paradox net dir is set to c:\
Any more hints? I just cant find the solution.
Thanks
Andreas
"Bill Todd" <XXXX@XXXXX.COM>writes:
Quote
If there are no old lock files then one or more of the machines that
access the tables has a different NetDir path set in the BDE
Administrator. All of the workstations must use exactly the same NetDir
path with one exception. If the machine that hosts the tables is also used
as a workstation the NetDir path on that machine can use a local drive
letter instead of a mapped drive letter as long as the rest of the path is
the same. One good solution is to use the same UNC path on all of the
machines.

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
 

Re: Transactions

Are there any files named PDOXUSRS.LCK or PARADOX.LCK anywhere on your
hard disk? If so, delete them. Also delete PDOXUSRS.NET.
--
Bill Todd (TeamB)
TeamB cannot answer questions received via email
 

Re: Transactions

I had some copies of my project on the local hdd including pdoxusrs.lck, paradox.lck and pdoxusrs.net.
Deleting them solved the problem (and my headache).
Thanks a lot
Andreas
"Bill Todd" <XXXX@XXXXX.COM>writes:
Quote
Are there any files named PDOXUSRS.LCK or PARADOX.LCK anywhere on your
hard disk? If so, delete them. Also delete PDOXUSRS.NET.

--
Bill Todd (TeamB)
TeamB cannot answer questions received via email