var s : TMemoryStream; begin s := TMemoryStream.Create; s.LoadFromFile('C:\temp.dwg'); s.Position := 0; with ADOQuery1 do begin Close; SQL.Clear; SQL.Add('insert into drawdwg (tabno,filedwg) values (:no,:dwg)'); Parameters.ParamByName('no').Value := Edit1.Text; Parameters.ParamByName('dwg').LoadFromStream(s,ftBlob); Execsql; end; s.Free; showmessage('save ok!'); 和这个类似,你改下,字段类型image,sql 7
procedure TDfczlrtx1.Button1Click(Sender: TObject); begin if openpicturedialog1.Execute=true then dbimage1.Picture.LoadFromFile(openpicturedialog1.FileName );end;
Table.edit;
DBimage1.Picture.LoadFromFile('');
DBimage1.CutToClipboard;
DBimage1.PasteFromClipboard;
Table.Post;
这样就可以装载图片了。JPG图片一定要这样,BMP可以省掉3、4句。
DBimage1.CutToClipboard;
DBimage1.PasteFromClipboard
有点问题
procedure TEntryPersonInfor.ViewImage;
Var
Jpg :TJpegImage ;
Path :String ;
begin
GetDir(0,Path) ;
Image1.Picture :=Nil ;
Image1.Repaint;
TempJpg :=Path+ '\TempJpg.Jpg' ;
Jpg :=TJpegImage.Create ;
TBlobField(adsMaster.FieldByName('Photo')).savetoFile(TempJpg) ;
Jpg.LoadFromFile(TempJpg);
Image1.Picture.Assign(Jpg);
Jpg.Free ;
end;
procedure TEntryPersonInfor.ViewImage;
Var
Jpg :TJpegImage ;
Path :String ;
begin
GetDir(0,Path) ;
Image1.Picture :=Nil ;
Image1.Repaint;
TempJpg :=Path+ '\TempJpg.Jpg' ;
Jpg :=TJpegImage.Create ;
TBlobField(adsMaster.FieldByName('Photo')).savetoFile(TempJpg) ;
Jpg.LoadFromFile(TempJpg);
Image1.Picture.Assign(Jpg);
Jpg.Free ;
end;
procedure TEntryPersonInfor.ViewImage;
Var
Jpg :TJpegImage ;
Path :String ;
begin
GetDir(0,Path) ;
Image1.Picture :=Nil ;
Image1.Repaint;
TempJpg :=Path+ '\TempJpg.Jpg' ;
Jpg :=TJpegImage.Create ;
TBlobField(adsMaster.FieldByName('Photo')).savetoFile(TempJpg) ;
Jpg.LoadFromFile(TempJpg);
Image1.Picture.Assign(Jpg);
Jpg.Free ;
end;
s : TMemoryStream;
begin
s := TMemoryStream.Create;
s.LoadFromFile('C:\temp.dwg');
s.Position := 0;
with ADOQuery1 do begin
Close;
SQL.Clear;
SQL.Add('insert into drawdwg (tabno,filedwg) values (:no,:dwg)');
Parameters.ParamByName('no').Value := Edit1.Text;
Parameters.ParamByName('dwg').LoadFromStream(s,ftBlob);
Execsql;
end;
s.Free;
showmessage('save ok!');
和这个类似,你改下,字段类型image,sql 7
begin
if openpicturedialog1.Execute=true then
dbimage1.Picture.LoadFromFile(openpicturedialog1.FileName );end;