Steve Riley
2012-12-31 07:29:49 UTC
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
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