1
117924
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm5.BitBtn1Click(Sender: TObject);
var
jts:TJPEGImage;
BlobStream:TBlobStream;
begin
jts:=TJPEGImage.Create;
xx.First;
table1.open;
with table1 do
begin
if table1.State<>dsedit then table1.edit;
jts.LoadFromFile(xxcfdz.Value);
BlobStream:=TBlobStream.Create(TBlobField(FieldByName('zp')),bmWrite); //zp为long row类型
BlobStream.Position:=0;
jts.SaveToStream(BlobStream);
if Table1.State in [dsedit,dsInsert] then table1.post;
//文件xxcfdz.Value指定的图存入table1的ZP字段;用下面代码读取成功。
query1.SQL.Clear;
query1.SQL.Add('update JJXT.V_JDC_CSZP');
query1.SQL.Add('set cszp=:db '); //cszp为long row类型
Query1.Sql.Add(' where JDCLSH=:dc');
// Query1.ParamByName('db').LoadFromFile(xxcfdz.Value, ftBlob);
Query1.ParamByName('db').LoadFromStream(BlobStream,ftBlob);
Query1.ParamByName('dc').AsString:=xxLsh.Value;
Query1.Prepare;
Query1.ExecSQL;
BlobStream.Free;
//用LoadFromFile和LoadFromStream更新cszp,用下面代码读取不成功。怎样才能更新cszp?
//JJXT.V_JDC_CSZP有十几万记录,只能用SQL更新,打开这个表要1分钟。
end;
table1.CLOSE;
jts.free;
end;
读取(网上的一段)
procedure loadimage;
Var
BlobStream:TBlobStream;
JpegImage:TJpegImage;
begin
BlobStream:=TBlobStream.Create(TblobField(table1.FieldByName('zp')),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;
var
jts:TJPEGImage;
BlobStream:TBlobStream;
begin
jts:=TJPEGImage.Create;
xx.First;
table1.open;
with table1 do
begin
if table1.State<>dsedit then table1.edit;
jts.LoadFromFile(xxcfdz.Value);
BlobStream:=TBlobStream.Create(TBlobField(FieldByName('zp')),bmWrite); //zp为long row类型
BlobStream.Position:=0;
jts.SaveToStream(BlobStream);
if Table1.State in [dsedit,dsInsert] then table1.post;
//文件xxcfdz.Value指定的图存入table1的ZP字段;用下面代码读取成功。
query1.SQL.Clear;
query1.SQL.Add('update JJXT.V_JDC_CSZP');
query1.SQL.Add('set cszp=:db '); //cszp为long row类型
Query1.Sql.Add(' where JDCLSH=:dc');
// Query1.ParamByName('db').LoadFromFile(xxcfdz.Value, ftBlob);
Query1.ParamByName('db').LoadFromStream(BlobStream,ftBlob);
Query1.ParamByName('dc').AsString:=xxLsh.Value;
Query1.Prepare;
Query1.ExecSQL;
BlobStream.Free;
//用LoadFromFile和LoadFromStream更新cszp,用下面代码读取不成功。怎样才能更新cszp?
//JJXT.V_JDC_CSZP有十几万记录,只能用SQL更新,打开这个表要1分钟。
end;
table1.CLOSE;
jts.free;
end;
读取(网上的一段)
procedure loadimage;
Var
BlobStream:TBlobStream;
JpegImage:TJpegImage;
begin
BlobStream:=TBlobStream.Create(TblobField(table1.FieldByName('zp')),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;