使用dbexpress控件面板中的TSqlServerMethod控件来调用
下面使用示例代码来说明:
服务器的自定义方法代码:
function TServerMethods1.inBeginSteam(inStream:widestring): boolean;
var
mem:TStringstream;
begin
try
result:=False;
if inStream='' then exit;
mem:=TStringstream.Create(inStream,TEncoding.Unicode);
mem.SaveToFile('C:/ccc.pdf');
result:=true;
finally
mem.Free;
mem:=nil;
end;
end;
客户端调用服务端自定义方法的代码:
procedure TForm1.BitBtn2Click(Sender: TObject);
var
f:tstringstream;
s:widestring;
begin
try
f:=tstringstream.Create('',TEncoding.Unicode);
f.LoadFromFile('c:/c1.pdf');
s:=f.DataString;
self.SqlServerMethod2.ServerMethodName:='TServerMethods1.inBeginSteam';
self.SqlServerMethod2.ParamByName('inStream').AsWideString:= s;
self.SqlServerMethod2.ExecuteMethod;
showmessage(self.SqlServerMethod2.ParamByName('ReturnParameter').AsString);
finally
f.Free;
f:=nil;
end;
end;