Ahmadi
2008-07-19 07:20:08 UTC
Hi
Im using following code to store and retrieve blob field:
procedure TCEngineForm.SaveButtonClick(Sender: TObject);
var
mem:TMemoryStream;
begin
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Add('Insert into myTable(ID,image) values (1,:p1);');
mem:=TMemoryStream.create;
mem.LoadFromFile('c:\ali.bmp');
SQLQuery1.Params.Clear;
SQLQuery1.Params.CreateParam(ftBlob,'p1',ptInput);
SQLQuery1.Params.ParamByName('p1').SetBlobData(mem.Memory,mem.Size);
SQLQuery1.ExecSQL;
end;
procedure TCEngineForm.LoadButtonClick(Sender: TObject);
var
mem:TMemoryStream;
stream:TStream;
begin
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Add('select * from myTable where id='+QuotedStr('1')+';');
SQLQuery1.ExecSQL;
SQLQuery1.open;
TBlobField(SQLQuery1.FieldByName('image')).SaveToFile('c:\ali2.bmp');
end;
After saving, only first bytes(approximately 1000 bytes) of "ali2.bmp" is
equal to "ali.bmp", and seems that DMBS don't send whole of my Blob field
data !
I tested the above code and some other blob save & retrieve methods from
internet, all return only a few of Blob field data correctly !!!
This mean that DBMS can not return rest of field data, and return
zero(#0).im confused!
Im using D2007, SQL Server (my blob field type in SQL is varbinary(Max),
other types also have same problem),and dbx for driver
Thanks for any help
Im using following code to store and retrieve blob field:
procedure TCEngineForm.SaveButtonClick(Sender: TObject);
var
mem:TMemoryStream;
begin
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Add('Insert into myTable(ID,image) values (1,:p1);');
mem:=TMemoryStream.create;
mem.LoadFromFile('c:\ali.bmp');
SQLQuery1.Params.Clear;
SQLQuery1.Params.CreateParam(ftBlob,'p1',ptInput);
SQLQuery1.Params.ParamByName('p1').SetBlobData(mem.Memory,mem.Size);
SQLQuery1.ExecSQL;
end;
procedure TCEngineForm.LoadButtonClick(Sender: TObject);
var
mem:TMemoryStream;
stream:TStream;
begin
SQLQuery1.SQL.Clear;
SQLQuery1.SQL.Add('select * from myTable where id='+QuotedStr('1')+';');
SQLQuery1.ExecSQL;
SQLQuery1.open;
TBlobField(SQLQuery1.FieldByName('image')).SaveToFile('c:\ali2.bmp');
end;
After saving, only first bytes(approximately 1000 bytes) of "ali2.bmp" is
equal to "ali.bmp", and seems that DMBS don't send whole of my Blob field
data !
I tested the above code and some other blob save & retrieve methods from
internet, all return only a few of Blob field data correctly !!!
This mean that DBMS can not return rest of field data, and return
zero(#0).im confused!
Im using D2007, SQL Server (my blob field type in SQL is varbinary(Max),
other types also have same problem),and dbx for driver
Thanks for any help
--
~~~~~~~~~~~
Best Regards
H.Ahmadi
~~~~~~~~~~~
Best Regards
H.Ahmadi