Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   MS SQL Server (https://www.clubdelphi.com/foros/forumdisplay.php?f=23)
-   -   Guardar Imagen de un TImage a un campo tipo image en sql server (https://www.clubdelphi.com/foros/showthread.php?t=84871)

Mechita 18-12-2013 16:11:13

Guardar Imagen de un TImage a un campo tipo image en sql server
 
Buenos Dias,

Necesito guardar una imagen que tengo en un TImage, en un campo image de una tabla en sql server.

He revisado varios hilos al respecto, pero nada de lo que he probado me funciona. Aparentemente la guarda pero cuando voy a consultarla para mostrarla me dice Bitmap Image Not Valid. La imagen debe ser mostrada en un reporte QuickReport.

Le muestro lo último que probe:

Para Guardar la imagen:

Código Delphi [-]
      with fquerylocate do
      begin
         bs := TMemoryStream.Create;
         if image1.Picture <> nil Then
          if image1.Picture.Graphic <> nil Then
            image1.Picture.Graphic.SaveToStream(bs);
        sql.clear;
        sql.Add('exec uSpinsCBBFacturaElectronica :oper,:imagen ');
        parambyname('oper').asstring:=codoper;
        ParamByName('imagen').LoadFromStream(bs, ftBlob);
        execsql;
      end;

Para mostrarla:
Código Delphi [-]
  
  oStream := busqueda.CreateBlobStream(Busqueda.FieldByName('cbb'), bmRead);
  oStream.Seek(0, soFromBeginning);
  QRImage2.Picture.Bitmap.LoadFromStream(oStream);
  oStream.Free;

La imagen en el TImage es de tipo BMP

Agradezco su ayuda,

Saludos

Neftali [Germán.Estévez] 19-12-2013 09:34:33

Intenta utilizar la propiedad Graphic en lugar de Bitmap, cuando recuperas la imagen.

Código Delphi [-]
 QRImage2.Picture.Graphic.LoadFromStream(oStream);


La franja horaria es GMT +2. Ahora son las 03:31:10.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi