Jens Froherz
2008-02-06 18:02:30 UTC
Picture not completely saved in MS SQL Server 2005 database...
Table in MS- SQL Server 2005
CREATE TABLE BILDTBL
(
IDNR INTEGER NOT NULL,
BILD IMAGE,
CONSTRAINT PK_BILDTBL PRIMARY KEY (IDNR)
);
procedure speicherebild(datei: String)
var
QU: TSQLQuery;
pic: TPicture;
ms: TMemoryStream;
begin
pic.loadFromFile(datei);
ms := TMemorystream.create;
try
pic.Graphic.SaveToStream(ms);
QU.Close;
QU.SQL.clear;
QU.SQL.ADD('INSERT INTO BILDTBL(IDNR,BILD)VALUES(:id,:bd)');
QU.Params[0].DataType := ftinteger;
QU.quleer1.Params[0].asinteger := 1;
QU.Params[0].DataType := ftBlob;
QU.quleer1.Params[0].assign(pic.Graphic); //oder
QU.quleer1.Params[0].loadfromstream(MS,ftBlob);
//beide Zuweisungen funktionieren gleich
QU.Execsql;
QU.Close;
finally
ms.free;
end;
end;
The procedure works with no error, but the Image in the Database Blob Field
(Type Image) is cutted at beginning and at the end. The picture is not
reproduceable.
What is wrong....????
Table in MS- SQL Server 2005
CREATE TABLE BILDTBL
(
IDNR INTEGER NOT NULL,
BILD IMAGE,
CONSTRAINT PK_BILDTBL PRIMARY KEY (IDNR)
);
procedure speicherebild(datei: String)
var
QU: TSQLQuery;
pic: TPicture;
ms: TMemoryStream;
begin
pic.loadFromFile(datei);
ms := TMemorystream.create;
try
pic.Graphic.SaveToStream(ms);
QU.Close;
QU.SQL.clear;
QU.SQL.ADD('INSERT INTO BILDTBL(IDNR,BILD)VALUES(:id,:bd)');
QU.Params[0].DataType := ftinteger;
QU.quleer1.Params[0].asinteger := 1;
QU.Params[0].DataType := ftBlob;
QU.quleer1.Params[0].assign(pic.Graphic); //oder
QU.quleer1.Params[0].loadfromstream(MS,ftBlob);
//beide Zuweisungen funktionieren gleich
QU.Execsql;
QU.Close;
finally
ms.free;
end;
end;
The procedure works with no error, but the Image in the Database Blob Field
(Type Image) is cutted at beginning and at the end. The picture is not
reproduceable.
What is wrong....????