我想一幅JPG图片保存到BLOB字段中,但不知道我的代码错在哪里?JPG图片根本就没有保存进BLOB字段里!运行到下面这句时提示 "Jpeg error #50",保存的图片仍然是一片空白. tblobfield(table1.FieldByName('photo')).LoadFromStream(tmp);
procedure TForm1.Button2Click(Sender: TObject);
var
tmp: tmemorystream;
tmpjpg: tjpegimage;
begin
tmp:=TmemoryStream.Create;
tmpjpg:=tjpegimage.create;
tmpjpg.LoadFromfile(openpicturedialog1.filename);
tmpjpg.savetostream(tmp);
tmp.seek(0,0);
table1.Edit;
tblobfield(table1.FieldByName('photo')).LoadFromStream(tmp);//这里出错
tmpjpg.free;
tmp.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
tmp: tmemorystream;
tmpjpg: tjpegimage;
begin
tmp:=TmemoryStream.Create;
tmpjpg:=tjpegimage.create;
tmpjpg.LoadFromfile(openpicturedialog1.filename);
tmpjpg.savetostream(tmp);
tmp.seek(0,0);
table1.Edit;
tblobfield(table1.FieldByName('photo')).LoadFromStream(tmp);//这里出错
tmpjpg.free;
tmp.Free;
end;
解决方案 »
- IdTCPServer 怎么接收来自IdTCPClient端的文件
- 两个表联合查询时,若其中一个表没没记录,则查出的结果怎么也没有记录?
- 在Delphi里面如何进行两个Form的互相调用?(基础问题、在线等待)
- 在线等待:如何调用StringGrid控件的DrawCell事件? 紧急!!!!!!!!!!
- 一个应该不是很难的查询问题
- Delphi 如何实现类似酷狗歌词的动态字幕?具体解释在下面
- 何为内存泄漏?
- 帮忙http://www.csdn.net/Expert/topic/438/438171.shtm
- 紧急求救!我把能给的分都给了!帮帮我吧。
- 业余程序员的专业问题
- 高手请进!快点吧,我很急
- TADOStoredProc怎么用?
var
tmp: tmemorystream;
tmpjpg: tjpegimage;
begin
tmp:=TmemoryStream.Create;
tmpjpg:=tjpegimage.create;
tmpjpg.LoadFromfile(openpicturedialog1.filename);
tmpjpg.savetostream(tmp);
//tmp.seek(0,0);不需要
table1.Edit;
tblobfield(table1.FieldByName('photo')).LoadFromStream(tmp);//这里出错
tmpjpg.free;
tmp.Free;
end;
var
tmp: tmemorystream;
begin
tmp:=TmemoryStream.Create;
tmp.loadfromfile(openpicturedialog1.filename);
table1.Edit;
tblobfield(table1.FieldByName('photo')).LoadFromStream(tmp);//这里出错
tmp.Free;
end;