Solved

Questions About Multiple Transactions  Handling on SQL Server 2000

Posted on 2006-11-28
3
414 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

Independent Software Vendors: 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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 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