原代码是这样的:
if OleContainer1.Modified then
begin
Stream := TBlobStream(table1.CreateBlobStream(table1.FieldByName(iv_oleField), bmReadWrite));
if OleContainer1.State <> osEmpty then
begin
OleContainer1.SaveToStream(Stream);
OleContainer1.Close ;
end
else
begin
Stream.Truncate ;
end;
Stream.Free;
end;
try
table1.Post;
except
on E: EDBEngineError do
;// pass
end;
错误提示:
EDBEngineError :Invalid BLOB length
procedure Tchgform.Button7Click(Sender: TObject);
var
filename :string;
Ms:TmemoryStream;
begin
if openpic.Execute then
begin
filename:=openpic.FileName;
ms := TMemorystream.Create();
try
dmform.ado_connect_yc.BeginTrans;
ms.LoadFromFile(filename);
Ms.Position :=0;
image1.Picture.LoadFromFile(filename);
with tadoquery.Create(self) do
begin
close;
connection:=dmform.ado_connect_yc;
sql.Clear;
sql.Add('select * from aa where id=1');
open;
edit;
TBlobfield(FieldByName('img')).LoadFromStream(Ms);
post;
free;
end;
dmform.ado_connect_yc.CommitTrans;
ms.Free;
except
begin
msgboxi('数据提交错误,你所做的更改无效,请重试');
dmform.ado_connect_yc.rollbacktrans;
end;
end;
if OpenDialog1.Execute then
begin
ADOQuery1.Edit;
ADOQuery1.FieldByName('Path').AsString :=ExtractFilePath(OpenDialog1.FileName) + ExtractFileName(OpenDialog1.FileName);
ADOQuery1.Post;
end;
你说的图片有多大?分块存储应该就是将图片划分成几份,然后每个字段存一份吧?比如说
一张大图片,你将其平均分成四份,上下左右各又成了一份图片,再用普通的保存图片的方法
保存进数据库.取出时,再将其四份取出来,再还原拼成一副大图片即可.要用到的函数,只一
个,BitBlt就够了.
相关格式,下面是一部分,你还是找帮助吧,或搜索一下,这儿应该有许多相关内容.
The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
BOOL BitBlt(
HDC hdcDest, // handle to destination device context
int nXDest, // x-coordinate of destination rectangle's upper-left corner
int nYDest, // y-coordinate of destination rectangle's upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source device context
int nXSrc, // x-coordinate of source rectangle's upper-left corner
int nYSrc, // y-coordinate of source rectangle's upper-left corner
DWORD dwRop // raster operation code
);