Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.pascal.delphi.misc > #431

SQL and Blobs

Newsgroups comp.lang.pascal.delphi.misc
Date 2012-12-30 23:29 -0800
Message-ID <1b2d57e8-1880-4bc5-8f7f-2f1867b9c4c4@googlegroups.com> (permalink)
Subject SQL and Blobs
From Steve Riley <giril01.sr@gmail.com>

Show all headers | View raw


Hi All
I am making a program which will store some photos of staff in a MSSQL database in a table with a Blob field
The table called “Images”  has only 2 fields RecordID and Photos,
RecordId is a Bigint with auto increment (Is Identity)
And the Photo is an Image data type.

And every time it gets to the DTable1.Post line it comes up with this Error: “Multiple-step operation generated errors, Check each status value”
I have tried this with a SQL Update command and it does the same
Does anyone know a way around this

There is only 1 record so far in this table and it is record number 9. But I still can’t save the image to it.

The code I use is below
The DTable Master is pointing to the main Master component which has the logons, I can see the records in the loop and it will find number 9 but then when I post it errors
I am using Deersoft ADO Components and Delphi 5, I have made loads of programs all to do with MSSQL but can’t save Blob files.

I have spent 2 days so far trying different codeto save an image into a MSSQL database.

Thanks in advance
Steve

Happy New Year to everyone.


procedure TMainForm.Button1Click(Sender: TObject);
var  Stream: TStream; Jpg: TJpegImage;
     loop:integer;
begin
     jpg := TJPEGImage.Create;
     jpg.Assign(Image_01.Picture.Graphic);
     stream := TMemoryStream.Create;
     stream.Position:= 0;
     jpg.SaveToStream(stream);
     DTable1.Active:=false;
     DTable1.TableName:='Images';
     DTable1.Active:=true;
     DTable1.First;
     t:=DTable1.RecordCount;
     for loop:=0 to t do begin
                         x:=DTable1.FieldByName('RecordID').asinteger;
                         if x=9 then begin
                                     DTable1.Edit;
                                     Stream := TMemoryStream.Create();
                                     (DTable1.FieldByName('Photo') as TBlobField).LoadFromStream(Stream);
                                    Stream.Position := 0;
                                     DTable1.Post;
                                     exit;
                                     end;
                         DTable1.next;
                         end;
     Jpg.free;Stream.free;
     DTable1.Active:=false;
end;

Thank you
Steve Riley

Back to comp.lang.pascal.delphi.misc | Previous | NextNext in thread | Find similar


Thread

SQL and Blobs Steve Riley <giril01.sr@gmail.com> - 2012-12-30 23:29 -0800
  Re: SQL and Blobs "Ph. B." <philippe_NO_SPAM_.boucault@voila.fr> - 2012-12-31 16:07 +0100
    Re: SQL and Blobs "Ph. B." <philippe_NO_SPAM_.boucault@voila.fr> - 2012-12-31 16:11 +0100

csiph-web