码迷,mamicode.com
首页 > 其他好文 > 详细

从数据池中捞取的存储过程控件使用完以后必须unprepare

时间:2017-04-10 09:44:12      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:unp   dsp   assigned   输入参数   var   null   not   sage   ack   

从数据池中捞取的存储过程控件使用完以后必须unprepare,否则会造成输入参数是仍是旧的BUG。

提示:动态创建的存储过程控件无此BUG。此BUG只限于从数据池中捞取的存储过程控件。

function TServerMethods1.spOpen(const accountNo, spName: WideString; inParams: OleVariant): OleVariant;
var
d: TfrmDB;
params: TParams;
i: Integer;
param: TFDParam;
begin
Result := null;
if (accountNo = ‘‘) or (spName = ‘‘) then
Exit;
d := GetDBPool(accountNo).Lock;
if not Assigned(d) then
Exit;
try
try
d.procOpen.Close;
d.procOpen.params.Clear;
d.procOpen.StoredProcName := spName;
d.procOpen.Prepare;
params := TParams.Create;
try
UnpackParams(inParams, params);
for i := 0 to params.Count - 1 do
begin
param := d.procOpen.FindParam(params[i].Name);
if not Assigned(param) then
Continue;
param.value := params[i].value;
end;
finally
params.Free;
end;
Result := d.dspProcOpen.Data;
except
on e: Exception do
begin
Result := null;
Log.WriteLog(‘TServerMethods1.spOpen ‘ + e.Message);
Exit;
end;
end;
finally
d.procOpen.Close;
d.procOpen.Unprepare;  // 从数据池中捞取的存储过程控件使用完以后必须unprepare
GetDBPool(accountNo).Unlock(d);
end;
end;

从数据池中捞取的存储过程控件使用完以后必须unprepare

标签:unp   dsp   assigned   输入参数   var   null   not   sage   ack   

原文地址:http://www.cnblogs.com/hnxxcxg/p/6687361.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!