Solved

Questions About Multiple Transactions  Handling on SQL Server 2000

Posted on 2006-11-28
3
418 Views
Last Modified: 2010-04-04
Dear Sir,
  I have another problem need your support!
  I am trying to start two transactions at a time on SQL Server 2000!
  I declaired aTD1, aTD2 as TTransactionDesc, and set TransactionID with 1 and 2. (Please reffer to the code posted below!)
  When starting transactions, error occurs: A transaction is already active!
  Is there anything I do wrong!

Thanks for your help again!

  The Params of my TSQLConnection:
    DriverName=MSSQL
    HostName=192.168.9.7
    DataBase=tdsys
    User_Name=db1
    Password=*****
    BlobSize=-1
    ErrorResourceFile=
    LocaleCode=0000
    MSSQL TransIsolation=ReadCommited
    OS Authentication=False
    Prepare SQL=False
    Multiple Transaction=True
 
The source code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DBXpress, StdCtrls, DB, SqlExpr;

type
  TForm1 = class(TForm)
    SQLConnection1: TSQLConnection;
    btnStart: TButton;
    btnEnd: TButton;
    lbStatus1: TLabel;
    lbStatus2: TLabel;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure btnEndClick(Sender: TObject);
    procedure btnStartClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    aTD1, aTD2: TTransactionDesc;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnEndClick(Sender: TObject);
begin
  SQLConnection1.Rollback(aTD1);
  lbStatus1.Caption := 'End Transaction 1';
  SQLConnection1.Rollback(aTD2);
  lbStatus2.Caption := 'End Transaction 2';
end;

procedure TForm1.btnStartClick(Sender: TObject);
begin
  aTD1.TransactionID  := 1;
  aTD1.IsolationLevel := xilREADCOMMITTED;
  aTD2.TransactionID  := 2;
  aTD2.IsolationLevel := xilREADCOMMITTED;
  try
    SQLConnection1.StartTransaction(aTD1);
    lbStatus1.Caption := 'Start Transaction 1';
    SQLConnection1.StartTransaction(aTD2);
    lbStatus2.Caption := 'Start Transaction 2';
  except
    on E: Exception do ShowMessage(E.Message);
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  SQLConnection1.Connected := False;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  SQLConnection1.Connected := True;
end;

end.
0
Comment
Question by:daniel710624
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 500 total points
ID: 18034804
well, not sure if i am correct (because of not having sql2000-server), but as far as i know is that you can with one connection only one transaction (or even nested transactions), but no independend transactions.

my advice would be to use different connections
(which may cause in two sessions, which are independend)

just a guess

meikl ;-)
0
 
LVL 21

Expert Comment

by:ziolko
ID: 18035538
agree with kretzschmar, use two different connections.

ziolko
0
 

Author Comment

by:daniel710624
ID: 18035814
So, 'Multiple Transaction=True'  in TSQLConnection.Params is useless?
I found that TSQLConnection.MultipleTransactionsSupported is False after TSQLConnection.Active set to True, does that means SQL Server doesn't support multi-transaction?
If that's......I will be damn..... :*o*:
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 78
tidtcpserver connection lost handle 2 124
How to load 2 images in same column in Delphi 2 81
Broadcast a message using ICS 2 51
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question