A
a1az
Unregistered / Unconfirmed
GUEST, unregistred user!
一个困扰我两天的问题,使用的是D6+InterBase6。用的是TQuery。
在InterBase6有一个保存jpeg图的字断Prod_Imag,这是我想的方法,可是总是失败。
那位大虾能否指点指定。
procedure TForm1.Button1Click(Sender: TObject);
Var
MS:TMemoryStream;
// Jpeg:TJpegImage;
sqlUpdate:String;
Temp: Boolean;
begin
sqlUpdate:='update Products set Prod_imag=rod_imag where ProdID=rodID';
if OpenDialog1 .Execute then
begin
try
Image1.Picture.LoadFromFile(OpenDialog1 .FileName);
except
on EInvalidGraphic do
Image1.Picture.Graphic := nil;
end;
Temp := Image1.Picture.Graphic is TJPEGImage;
if Temp then
begin
MS:=TMemoryStream.Create ;
TJPEGImage( Image1 .Picture .Graphic).SaveToStream(MS);
Jpeg.LoadFromFile(OpenPictureDialog1.FileName ) ;
Jpeg.SaveToStream(MS);}
MS.Position :=0;
Table1 .Open ;
Table1 .First;
Query1 .SQL .Clear ;
Query1 .SQL .Add(sqlUpdate);
Query1 .ParamByName('Prod_imag').SetBlobData(MS.memory,MS.size);
//可以这样吗?我是不得要领呀。
Query1 .ParamByName('ProdID').AsString:=table1.FieldByName('ProdID').AsString ;
Query1 .ExecSQL ;
Table1 .Close;
Table1 .Open;
end;
end;
end;
在InterBase6有一个保存jpeg图的字断Prod_Imag,这是我想的方法,可是总是失败。
那位大虾能否指点指定。
procedure TForm1.Button1Click(Sender: TObject);
Var
MS:TMemoryStream;
// Jpeg:TJpegImage;
sqlUpdate:String;
Temp: Boolean;
begin
sqlUpdate:='update Products set Prod_imag=rod_imag where ProdID=rodID';
if OpenDialog1 .Execute then
begin
try
Image1.Picture.LoadFromFile(OpenDialog1 .FileName);
except
on EInvalidGraphic do
Image1.Picture.Graphic := nil;
end;
Temp := Image1.Picture.Graphic is TJPEGImage;
if Temp then
begin
MS:=TMemoryStream.Create ;
TJPEGImage( Image1 .Picture .Graphic).SaveToStream(MS);
Jpeg.LoadFromFile(OpenPictureDialog1.FileName ) ;
Jpeg.SaveToStream(MS);}
MS.Position :=0;
Table1 .Open ;
Table1 .First;
Query1 .SQL .Clear ;
Query1 .SQL .Add(sqlUpdate);
Query1 .ParamByName('Prod_imag').SetBlobData(MS.memory,MS.size);
//可以这样吗?我是不得要领呀。
Query1 .ParamByName('ProdID').AsString:=table1.FieldByName('ProdID').AsString ;
Query1 .ExecSQL ;
Table1 .Close;
Table1 .Open;
end;
end;
end;