Article View: borland.public.delphi.database.dotnet
Article #645Why MySQL for .NET Transaction doesn't work ??
From: ice
Date: Fri, 24 Sep 2004 03:33
Date: Fri, 24 Sep 2004 03:33
26 lines
1532 bytes
1532 bytes
I use the following code trying to insert two rows, it is supposed to commit
all
the changes only when the Commit() is called. However, I don't know why it
will commit the change to table just after calling ExecuteNonQuery()
is there anyone can help ? Thx a lot !
tran:=con.BeginTransaction(IsolationLevel.ReadCommitted);
try
cmd:=con.CreateCommand; //dri.GetDBCommand;
cmd.Connection:=con;
cmd.Transaction:=tran;
cmd.CommandText:='insert into abc values ("xa123")';
cmd.ExecuteNonQuery;
cmd.CommandText:='insert into abc values ("xa1234")';
cmd.ExecuteNonQuery;
tran.Commit;
except
tran.Rollback;
end;
ps: I'm using MYSQL 4
Technical Details
Message-ID:
<41539575$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1effe6,b5cd2e3cca8da7f1,start X-Google-Attributes: gid1effe6,public X-Google-Language: ENGLISH,ASCII-7-bit From: <ice@ice.com> Newsgroups: borland.public.delphi.database.dotnet Subject: Why MySQL for .NET Transaction doesn't work ?? Date: Fri, 24 Sep 2004 11:33:10 +0800 Lines: 28 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 210.184.31.164 Message-ID: <41539575$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1095996789 210.184.31.164 (23 Sep 2004 20:33:09 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail