我用BDE向sqlserver存储图片,如果图片稍大为什么总报invalid blob length阿,sql server中图片类型为image,改称binary后,就报invalid class typecast,请高手帮个忙啊,我是这样写的
procedure TForm1.savetodbClick(Sender: TObject);
var
strm: TMemoryStream;
ext: String;
begin
if image1.picture.Graphic <> nil then
begin
ext:=extractfileext(openpicturedialog1.FileName );
strm := tmemorystream.Create ;
try
image1.Picture.Graphic.SaveToStream(strm);
query1.Edit ;
strm.Position :=0;
tblobfield(query1.FieldByName('photo')).LoadFromStream(strm);
query1.Post ;
finally
strm.Free ;
end;
end;
end;
procedure TForm1.savetodbClick(Sender: TObject);
var
strm: TMemoryStream;
ext: String;
begin
if image1.picture.Graphic <> nil then
begin
ext:=extractfileext(openpicturedialog1.FileName );
strm := tmemorystream.Create ;
try
image1.Picture.Graphic.SaveToStream(strm);
query1.Edit ;
strm.Position :=0;
tblobfield(query1.FieldByName('photo')).LoadFromStream(strm);
query1.Post ;
finally
strm.Free ;
end;
end;
end;
解决方案 »
- 关于ADOdataset的批量跟新问题
- 如何关联单元文件
- Delphi调用VISA库时,如何读取双指针所反馈的值? 赠送10分
- 为什么Delphi里的Memo控件,在win2000下读取文本文件内容,会有乱码?
- 怎样使光标从行头移到最后一行的行尾!
- 水圆对骂,信誉减少,“痛快”,散分!!!!
- 导入了一个activex控件后,怎样才能像VB中的“对象浏览器”来了解它所封装的类,以及各类成员函数的属性的意义、使用格式等信息?谢谢!
- 为何检测Strl,Ctrl等鍵时,常常失效?
- 怎样才能对DBEDIT,DBMEMO组件进行编辑?
- 如何替换string中的特定字符为另一个字符?
- BDE数据库怎么打包给别人!!
- 怎样动态申请内存、释放内存?常见的对象列表类是什么?
count
MaxWidth=100;
MaxHeight=100;
var
strm: TMemoryStream;
ext: String;
widtj,height,tpint:integer;
begin
if image1.picture.Graphic <> nil then
begin
if image1.width>=image1.height then
tpint:=round(image1.width div MaxWidth)
else
tpint:=round(image1.height div MaxHeight);
width:=image1.width div tpint;
height:=image1.height div tpint;
image1.width:=width;
image1.height:=height; ext:=extractfileext(openpicturedialog1.FileName );
strm := tmemorystream.Create ;
try
image1.Picture.Graphic.SaveToStream(strm);
query1.Edit ;
strm.Position :=0;
tblobfield(query1.FieldByName('photo')).LoadFromStream(strm);
query1.Post ;
finally
strm.Free ;
end;
end;
end;
用image类型就可以了,不用改为binary