X
xiecc
Unregistered / Unconfirmed
GUEST, unregistred user!
Oracle8.1.6 Blob字段保存图象总是出错,我已经把能用的方法全用了
方法一:
with query1 do
begin
Edit;
ImagePic.Picture.SaveToFile(sPicFileName);
TBlobField(FieldByName('Picture')).LoadFromFile(sPicFileName);
Post;
end;
方法二:
Query.Close;
Query.SQL.Clear;
Query.SQL.Add('INSERT myimages VALUEfilename,EMPTY_BLOB())');
Query.ParamByName('filename').AsString := DBEdit1.Text;
Query.ExecSQL;
Query.SQL->Clear;
Query.SQL->Add('UPDATE myimages SET images=ic WHERE filename=:filename');
Query.ParamByName("filename").AsString := DBEdit1.Text;
Query.ParamByName('pic').LoadFromStream(MyStream,ftOraBlob);;
Query.ExecSQL;
方法三:
procedure saveimage;
Var
BlobStream:TBlobStream;
JpegImage:TJpegImage;
begin
try
with Frm_DossierView.query1 do
try
JpegImage:=TJpegImage.Create;
BlobStream:=TBlobStream.Create(TBlobField(FieldByName('WSNR')),bmWrite);
BlobStream.Position:=0;
// BlobStream.Truncate;
JpegImage:=TJpegImage(Frm_DossierView.image1.Picture.Graphic);
JpegImage.SaveToStream(BlobStream);
finally
if Not Assigned(BlobStream) then BlobStream.Free;
if Not Assigned(JpegImage) then JpegImage.Free;
end;
except
end;
end;
读取
procedure loadimage;
Var
BlobStream:TBlobStream;
JpegImage:TJpegImage;
begin
try
BlobStream:=TBlobStream.Create(TblobField(Frm_DossierView.Query1.FieldByName('WSNR')),bmRead);
if BlobStream.Size>0 then
begin
JpegImage:=TJpegImage.Create;
JpegImage.LoadFromStream(BlobStream);
Frm_DossierView.Image1.Picture.Assign(JpegImage);
end
else
Frm_DossierView.Image1.Picture:=nil;
Finally
if Not Assigned(BlobStream) then BlobStream.Free;
if Not Assigned(JpegImage) then JpegImage.Free;
End;
end;
可最后返回的错误都是一样的:
“General SQL error.ORA-22275:指定LOB定位器无效”
以前用MS SQL Server从来不曾出过这种事,哪位大侠快救救我吧!
方法一:
with query1 do
begin
Edit;
ImagePic.Picture.SaveToFile(sPicFileName);
TBlobField(FieldByName('Picture')).LoadFromFile(sPicFileName);
Post;
end;
方法二:
Query.Close;
Query.SQL.Clear;
Query.SQL.Add('INSERT myimages VALUEfilename,EMPTY_BLOB())');
Query.ParamByName('filename').AsString := DBEdit1.Text;
Query.ExecSQL;
Query.SQL->Clear;
Query.SQL->Add('UPDATE myimages SET images=ic WHERE filename=:filename');
Query.ParamByName("filename").AsString := DBEdit1.Text;
Query.ParamByName('pic').LoadFromStream(MyStream,ftOraBlob);;
Query.ExecSQL;
方法三:
procedure saveimage;
Var
BlobStream:TBlobStream;
JpegImage:TJpegImage;
begin
try
with Frm_DossierView.query1 do
try
JpegImage:=TJpegImage.Create;
BlobStream:=TBlobStream.Create(TBlobField(FieldByName('WSNR')),bmWrite);
BlobStream.Position:=0;
// BlobStream.Truncate;
JpegImage:=TJpegImage(Frm_DossierView.image1.Picture.Graphic);
JpegImage.SaveToStream(BlobStream);
finally
if Not Assigned(BlobStream) then BlobStream.Free;
if Not Assigned(JpegImage) then JpegImage.Free;
end;
except
end;
end;
读取
procedure loadimage;
Var
BlobStream:TBlobStream;
JpegImage:TJpegImage;
begin
try
BlobStream:=TBlobStream.Create(TblobField(Frm_DossierView.Query1.FieldByName('WSNR')),bmRead);
if BlobStream.Size>0 then
begin
JpegImage:=TJpegImage.Create;
JpegImage.LoadFromStream(BlobStream);
Frm_DossierView.Image1.Picture.Assign(JpegImage);
end
else
Frm_DossierView.Image1.Picture:=nil;
Finally
if Not Assigned(BlobStream) then BlobStream.Free;
if Not Assigned(JpegImage) then JpegImage.Free;
End;
end;
可最后返回的错误都是一样的:
“General SQL error.ORA-22275:指定LOB定位器无效”
以前用MS SQL Server从来不曾出过这种事,哪位大侠快救救我吧!