T
tjcjh
Unregistered / Unconfirmed
GUEST, unregistred user!
有一表名为ibm2000.dagl存放在SQL Server,两个字段(FileName, Blob),需要将
Word文件名存放在FileName字段,Word文件存放在Blob字段中,始终保存不到SQL Server,
代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
fn : String;
ms : TMemoryStream;
begin
if OpenDialog1.Execute then
begin
fn:= ExtractFileName(OpenDialog1.FileName);
ms:= TMemoryStream.Create;
try
OleContainer1.CreateObjectFromFile(OpenDialog1.FileName, False);
OleContainer1.SaveToStream(ms);
Query1.SQL.Clear;
Query1.SQL.Add('insert into ibm2000.dagl(FILENAME, BLOB) values('''+ fn+ ''', ms)');
Query1.ExecSQL;
finally
ms.Free;
end;
end;
end;
请各位高手指点一下,问题出在哪里?!谢谢。
Word文件名存放在FileName字段,Word文件存放在Blob字段中,始终保存不到SQL Server,
代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
fn : String;
ms : TMemoryStream;
begin
if OpenDialog1.Execute then
begin
fn:= ExtractFileName(OpenDialog1.FileName);
ms:= TMemoryStream.Create;
try
OleContainer1.CreateObjectFromFile(OpenDialog1.FileName, False);
OleContainer1.SaveToStream(ms);
Query1.SQL.Clear;
Query1.SQL.Add('insert into ibm2000.dagl(FILENAME, BLOB) values('''+ fn+ ''', ms)');
Query1.ExecSQL;
finally
ms.Free;
end;
end;
end;
请各位高手指点一下,问题出在哪里?!谢谢。