
可以定义大字段,然后把存入 :
var
Field1:TBlobField;
begin
qzybodyOpen;
qzybodyappend;
try
Field1:=TBlobField(qzybodyFieldbyname('object_body'));
Field1LoadFromFile('路径');
except
end;
qzybodyPost;
end;
用stream和Tblod
procedure TForm1Button1Click(Sender: TObject);
var stream:TMemoryStream;
begin
try
stream:=TADOBlobStreamCreate;
with ADOQuery1 do
begin
close;
sqltext:='select from tp where bh='+QuotedStr(Text1);
open;
TBlobField(FieldByName('photo'))SaveToStream(stream);
imgPictureBitmapLoadFromStream(stream);
close;
end;
finally
streamFree;
end;
end;
image1PictureBitmapSaveToStream(stream);
image2CanvasDraw(0,0,Image1PictureBitmap);
with adotable1 do
begin
close;
Open;
edit;
TBlobField(adotable1FieldByName('image'))LoadFromStream(stream);
post;
TBlobField(adotable1FieldByName('image'))SaveToStream();
// image2PictureBitmapAssign();
end;
finally
streamFree;
end;
end;
第一步://获取当前选择的thispictureBox1Image = ImageFromStream(thisopenFileDialog1OpenFile());//获取当前的路径string path = openFileDialog1FileNameToString();//将制定路径的添加到FileStream类中FileStream fs = new FileStream(path, FileModeOpen, FileAccessRead);//通过FileStream对象实例化BinaryReader对象BinaryReader br = new BinaryReader(fs);//通过BinaryReader类对象的ReadBytes()方法将FileStream类对象转化为二进制数组byte[] imgBytesIn = brReadBytes(ConvertToInt32(fsLength));第二步://将添加到数据库中string sql="insert into pic values(@pic)";SqlParameter[] param = new SqlParameter[] { new SqlParameter("@pic", imgBytesIn) };DBHelperGetExecuteQuery(sql, param);第三步://将从数据库中取出string sql="select from pic where id=0";SqlDataReader reader = DBHelperGetExecuteReader(sql, null);MemoryStream mss = null;
以上就是关于DELPHI 怎么才可以把 Image1 保存到 DAT 数据库中全部的内容,包括:DELPHI 怎么才可以把 Image1 保存到 DAT 数据库中、delphi中如何把Image控件导入到数据库中、如何将图片插入到数据库中等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)