E
errorboy
Unregistered / Unconfirmed
GUEST, unregistred user!
有一个Word或其它类型的文件要存在SQLServer2000数据库中,单层结构没有问题。现在转为Com+,客户端找到文件变转换为文件流(TFileStream),服务器端一个方法往数据库中存贮文件,该方法中与文件流对应的传入参数设为olevariant不匹配,不知在客户端和服务器端应该用什么变量来传输文件流?请高手指教。
服务器端程序(方法):
procedure TDbFile.InsertFile(const FileNum: WideString;
InsertDate: TDateTime;
FileX: WordBool;
out VResult: OleVariant);
begin
with adocommanddo
begin
commandtext:='insert into x技术文件 (文件编码,录入时间,内容) valuesa,:b,:c)';
parameters[0].Value:=FileNum;
parameters[1].Value:=InsertDate;
parameters[2].Value:=FileX;
try
execute;
VResult:='ok';
except
VResult:='Failure';
end;
end;
end;
客户端程序:
unit x;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MyDbFile_TLB;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
mytest:iDbFile;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
FileX:TFilestream;
zzlevariant;
begin
Filex:=TFileStream.Create('d:/q.doc',fmOpenRead);
Filex.Position:=0;
mytest:=coDbFile.CreateRemote('198.198.198.1');
mytest.InsertFile('xtest',now,filex,zz);
end;
end.
服务器端程序(方法):
procedure TDbFile.InsertFile(const FileNum: WideString;
InsertDate: TDateTime;
FileX: WordBool;
out VResult: OleVariant);
begin
with adocommanddo
begin
commandtext:='insert into x技术文件 (文件编码,录入时间,内容) valuesa,:b,:c)';
parameters[0].Value:=FileNum;
parameters[1].Value:=InsertDate;
parameters[2].Value:=FileX;
try
execute;
VResult:='ok';
except
VResult:='Failure';
end;
end;
end;
客户端程序:
unit x;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MyDbFile_TLB;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
mytest:iDbFile;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
FileX:TFilestream;
zzlevariant;
begin
Filex:=TFileStream.Create('d:/q.doc',fmOpenRead);
Filex.Position:=0;
mytest:=coDbFile.CreateRemote('198.198.198.1');
mytest.InsertFile('xtest',now,filex,zz);
end;
end.