为什么不能提交,我很急,谢谢!(在线等待) (200分)

  • 主题发起人 主题发起人 yongshiok
  • 开始时间 开始时间
Y

yongshiok

Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下
ADOConnection1.BeginTrans;
try
ADODataSet1.Edit;
ADODataSet1.Fields[1].AsString:='bbbbbbbbbb';
ADODataSet1.Post;
adoconnection1.CommitTrans;
except
adoconnection1.RollbackTrans;
end;
执行到CommitTrans时,报错“ITransaction::Commit 或Itransaction::Abort被调用,并且对象处于
zombie状态”。
 
if adoconnection1.InTransaction then adoconnection1.CommitTrans;
ADOConnection1.BeginTrans;
try
ADODataSet1.Edit;
ADODataSet1.Fields[1].AsString:='bbbbbbbbbb';
ADODataSet1.Post;
adoconnection1.CommitTrans;
except
adoconnection1.RollbackTrans;
end;

 
to 张剑波
还是一样的报错。
 
ADODataSet换成adotable试试
 
你装那两个补丁了吗?
 
下列实际代码测试通过:if adoconnection1.InTransaction then adoconnection1.CommitTrans;
ADOConnection1.BeginTrans;
try
ADODataSet1.Edit;
ADODataSet1.Fields[1].AsString:='1';
ADODataSet1.Post;
adoconnection1.CommitTrans;
except
adoconnection1.RollbackTrans;
end;
是你数据库的原因吧?或者你是多层的?

 
to 张剑波
还报一样的错。
to svw0506
已装好补丁,d5adoupdate2,D5ADOUpgrade,D5EntUpdate。
 
to 张剑波
Cursorlocation
设为
clUseServer
是否有影响?
 
我在D6下用了没有错!
 
只要你的单层的,不要想的那么复杂化。
close all
exit
reboot
new application
重新做一遍。
 
我在d5,win 2k server,2个补丁D5EntUpdate,d5adoupdate2,下没有错
 
很奇怪在,在Cursorlocation
设为clUseClient不报错设为
clUseServer
时报错,程序要求速度,记录数有30万,所以只能用clUseServer
 
Cursorlocation:=clUseServer
cursortype:=ctkeyset后 ,test ok!!!!
 
to 张剑波,
Cursorlocation

clUseServer
吗?
 
能不能把你的pas 和dfm 贴上来,我试试,谢谢!
 
我帮你在Sql Server 2000环境下测试了一下,很正常的,并没有你说的现象发生。
不会是你的操作系统有问题吧?
 
procedure TForm1.Button1Click(Sender: TObject);
begin
if adoconnection1.InTransaction then adoconnection1.CommitTrans;
ADOConnection1.BeginTrans;
try
ADODataSet1.next;//不断的换行修改
ADODataSet1.Edit;
ADODataSet1.Fields[1].AsString:='2222';
ADODataSet1.Post;
adoconnection1.CommitTrans;
except
adoconnection1.RollbackTrans;
end;
_______________object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 232
Top = 160
Width = 75
Height = 25
Caption = 'Button1'
TabOrder = 0
OnClick = Button1Click
end
object Panel1: TPanel
Left = 216
Top = 56
Width = 185
Height = 41
Caption = 'Panel1'
TabOrder = 1
end
object Edit1: TEdit
Left = 40
Top = 136
Width = 121
Height = 21
TabOrder = 2
Text = 'Edit1'
end
object Button2: TButton
Left = 88
Top = 200
Width = 75
Height = 25
Caption = 'Button2'
TabOrder = 3
end
object ADOConnection1: TADOConnection
Connected = True
ConnectionString =
'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:/My' +
' Documents/db1.mdb;Mode=Share Deny None;Extended Properties="";J' +
'et OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB' +
':Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database' +
' Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Gl' +
'obal Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet ' +
'OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=Fa' +
'lse;Jet OLEDB:Don'#39't Copy Locale on Compact=False;Jet OLEDB:Compa' +
'ct Without Replica Repair=False;Jet OLEDB:SFP=False'
LoginPrompt = False
Mode = cmShareDenyNone
Provider = 'Microsoft.Jet.OLEDB.4.0'
Left = 88
Top = 48
end
object ADODataSet1: TADODataSet
Active = True
Connection = ADOConnection1
CursorLocation = clUseServer
CommandText = 'select * from xyz'
Parameters = <>
Left = 128
Top = 48
end
end
 
to 张剑波 :
我试过了,连接 Access 没有 问题
但我连接的是SQL Server,你再试试SQL Server
to Archerfl:
为了这个我已经重装了系统,问题依旧。
 
后退
顶部