关于WebService的一个很怪的问题 ( 积分: 200 )

  • 主题发起人 主题发起人 mysuperbull
  • 开始时间 开始时间
M

mysuperbull

Unregistered / Unconfirmed
GUEST, unregistred user!
下面是函数代码:
function TSimWebService.SaveBill(BillType: String; SQL: OleVariant; StartTrans : Boolean;
out Error: String; out NewBillID : String): Boolean; stdcall;
var
SaveSQL : String;
iDm : Integer;
I : Integer;
begin
Result := False;
if not ConnectDB('MSSQLServer', Error) then
Exit;

NewBillID := GetMaxNewBillID(BillType, Error);
if Trim(NewBillID) = '' then
begin
Error := '获取最新单据编号失败!';
Exit;
end;
if StartTrans then
begin
if DMObj.ADOConnection.BeginTrans < 1 then
begin
Error := '启动事务失败!';
Exit;
end;
if not DMObj.ADOConnection.InTransaction then
begin
Error := '不在事务中!';
Exit;
end;
end;
iDm := VarArrayDimCount(SQL);
try
for I := VarArrayLowBound(SQL,iDm) to VarArrayHighBound(SQL,iDm) do
begin
DMObj.AQ_RunSQL.Close;
DMObj.AQ_RunSQL.SQL.Clear;
SaveSQL := SQL;
SaveSQL := Format(SaveSQL,[NewBillID]);
DMObj.AQ_RunSQL.SQL.Add(SaveSQL);
DMObj.AQ_RunSQL.ExecSQL;
end;
if DMObj.ADOConnection.InTransaction then
DMObj.ADOConnection.CommitTrans;
except
if DMObj.ADOConnection.InTransaction then
DMObj.ADOConnection.RollbackTrans;
Error := '以下SQL语句执行失败:'#13 + SaveSQL;
ReSult := False;
Exit;
end;

ReSult := True;
end;

Client端调用该函数时报地址访问错,但是SQL语句成功提交到数据库中
 
输入/输出字符串参数不要用string类型,用BSTR(WideString)
 
后退
顶部