首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

DA中直接运行SQL命令,并返回影响行数

Posted on 2011-08-09 12:06  colincode  阅读(626)  评论(0编辑  收藏  举报

1、客户端直接运行SQL命令,使用TDARemoteCommand

2、服务器端直接运行SQL命令,使用TDALocalCommand



function
DeleteRowFromTable1(aID:integer):integer;
var
lCommand:TDALocalCommand;
linp, lout: DataParameterArray;
i: integer;
begin
try
lCommand:=TDALocalCommand.Create(nil);
lCommand.ServiceName:='MyService';
linp := DataParameterArray.Create;
try
with linp.Add do begin
Name := UTF8Encode('ID');
Value := aID;
end;
lCommand.Execute('DeleteRow',linp, lout);
if lout <> nil then
for I := 0 to lout.Count - 1 do
if UTF8ToString(lout[i].Name) = 'ErrorCode' then
Result := lout[i].Value;
finally
linp.Free;
lOut.Free;
end;
finally
lCommand.Destroy;
end;
end;