When I create a table within a transaction this table is not accessible in transaction but all other table that created before transaction are accessible. How can I solve this problem?
procedure TForm1.Button1Click(Sender: TObject);
var MyAdo:TADOQuery;
a,b:integer;
begin
AdoConnection1.ConnectionString := 'Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=MyPCNAME'
MyAdo:=TAdoQuery.Create(Application);
MyAdo.Connection := ADOConnection1;
MyAdo.SQL.Add('Create table tempdb..test1 (TBID int) '
+' Insert Into tempdb..test1 Values (1) '
+' Insert Into tempdb..test1 Values (2) '
);
MyAdo.ExecSQL;
ADOConnection1.BeginTrans;
MyAdo.SQL.Clear;
MyAdo.SQL.Add('Create table tempdb..test2 (TBID int) ');
MyAdo.ExecSQL;
MyAdo.SQL.Clear;
MyAdo.SQL.Add('Select max(TBID) Mx1 From TempDb..Test1 ');
MyAdo.Open;
A:=MyAdo.FieldByName('Mx1').AsInteger; //Result:2
MyAdo.SQL.Clear;
MyAdo.SQL.Add('Select max(TBID) Mx2 From TempDb..Test2 ');
MyAdo.Open;
B:=MyAdo.FieldByName('Mx2').AsInteger; //Deadlock!!!!!!!!! It need to force the application to close
ADOConnection1.CommitTrans;
end;