我在中间件中写一个Create Table的语句,做法为:
1.使用TADOQuery,直接对其进行赋值,没有做其他属性设置
2.代码如下:
if ConnectDB then
begin
try
Connect_db.BeginTrans;
try
with tempUpdateQuery do
begin
Close;
SQL.Clear;
SQL.Add(vSQL);
ExecSQL;
end;
Connect_db.CommitTrans;
except
on e:Exception do
begin
OutMsg :='执行语句错误:' + E.Message;
Connect_db.RollbackTrans;
end;
end;
finally
stopdb;
end;
end;
遇到的问题:
1.如果加上事务处理的话,会一直报:无法在此会话中启动更多的事务(其他地方干干净净,没有做过事务处理)
2.不用事务处理,能正确执行,但是执行完毕后我到服务器中select 该表,发现被锁现象(或者说事务未能提交)。这是何原因呢?