Y
yvping
Unregistered / Unconfirmed
GUEST, unregistred user!
请教高手老问题: 关于OLEContainer<==>Blob Field
数据库是oracle7.3, DElphi是 D5, 程序分3部分,写入库BLOB字段是没有出错的,
总是在从库BLOB字段读到 OLEContainer中时报错: '%1已存在'.
请高手指点,送上150分以表谢意,(我水平较差,留下100分下次用,惭愧!惭愧!)
//1: 选择'文件' 到 'OLEContainer'
procedure TFormKblist.BtnSeleFileClick(Sender: TObject);
begin
if (OleContainerKbsm.State = osEmpty) or (MessageDlg('Delete current OLE object?', mtConfirmation, mbOkCancel, 0) = mrOk) then begin
OleContainerKbsm.InsertObjectDialog;
if (OleContainerKbsm.State <> osEmpty) then
OleContainerKbsm.doverb(1);
end;
end;
//2: 'OLEContainer' 存入数据库 Bolb字段'SM'
procedure TFormKblist.BtnSaveToDBClick(Sender: TObject);
var
OleStream : TMemoryStream;
begin
OleStream := TMemoryStream.Create;
try
OleContainerKbsm.SaveToStream(OleStream);
OleStream.Position := 0; //回零点
tbKBLIST.edit;
tBlobfield(tbKBLIST.FieldByName('sm')).LoadFromStream(OleStream);
tbKBLIST.Post ;
finally
OleStream.Free;
end;
end;
//3: 从数据库 Bolb字段'SM' 读数据到'OLEContainer'
procedure TFormKblist.BtnFetchBlobClick(Sender: TObject);
var
blobstream : tBlobStream;
OleStream : TMemoryStream;
begin
OleStream := TMemoryStream.Create;
OleStream.Position := 0;
try
blobstream := tBlobstream.create(tbKBLIST.FieldByName('sm') as tblobfield, bmread);
OleStream.copyfrom(blobstream, 0);
OleStream.Position := 0;
if (OleContainerKbsm.State = osEmpty) or (MessageDlg('Delete current OLE object?', mtConfirmation, mbOkCancel, 0) = mrOk) then begin
OleContainerKbsm.LoadFromStream(OleStream); //总是这一行报错: '%1已存在'
//OleContainerKbsm.DoVerb(1); //显示
end;
finally
OleStream.Free;
end;
end;
数据库是oracle7.3, DElphi是 D5, 程序分3部分,写入库BLOB字段是没有出错的,
总是在从库BLOB字段读到 OLEContainer中时报错: '%1已存在'.
请高手指点,送上150分以表谢意,(我水平较差,留下100分下次用,惭愧!惭愧!)
//1: 选择'文件' 到 'OLEContainer'
procedure TFormKblist.BtnSeleFileClick(Sender: TObject);
begin
if (OleContainerKbsm.State = osEmpty) or (MessageDlg('Delete current OLE object?', mtConfirmation, mbOkCancel, 0) = mrOk) then begin
OleContainerKbsm.InsertObjectDialog;
if (OleContainerKbsm.State <> osEmpty) then
OleContainerKbsm.doverb(1);
end;
end;
//2: 'OLEContainer' 存入数据库 Bolb字段'SM'
procedure TFormKblist.BtnSaveToDBClick(Sender: TObject);
var
OleStream : TMemoryStream;
begin
OleStream := TMemoryStream.Create;
try
OleContainerKbsm.SaveToStream(OleStream);
OleStream.Position := 0; //回零点
tbKBLIST.edit;
tBlobfield(tbKBLIST.FieldByName('sm')).LoadFromStream(OleStream);
tbKBLIST.Post ;
finally
OleStream.Free;
end;
end;
//3: 从数据库 Bolb字段'SM' 读数据到'OLEContainer'
procedure TFormKblist.BtnFetchBlobClick(Sender: TObject);
var
blobstream : tBlobStream;
OleStream : TMemoryStream;
begin
OleStream := TMemoryStream.Create;
OleStream.Position := 0;
try
blobstream := tBlobstream.create(tbKBLIST.FieldByName('sm') as tblobfield, bmread);
OleStream.copyfrom(blobstream, 0);
OleStream.Position := 0;
if (OleContainerKbsm.State = osEmpty) or (MessageDlg('Delete current OLE object?', mtConfirmation, mbOkCancel, 0) = mrOk) then begin
OleContainerKbsm.LoadFromStream(OleStream); //总是这一行报错: '%1已存在'
//OleContainerKbsm.DoVerb(1); //显示
end;
finally
OleStream.Free;
end;
end;