Saving blob into MSSQL using dbexpress in Delphi

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
loogieboy
Posts: 1
Joined: Tue 06 Dec 2005 11:04
Location: Czech Republic

Saving blob into MSSQL using dbexpress in Delphi

Post by loogieboy » Tue 06 Dec 2005 11:26

I not able to save blob variable into MSSQL server using dbexpress with corelab dlls in Delphi. Using this code. There is no problem or error during saving, but at the end the blob field is empty. I've tried diferent ways to seve it, but nothing works.
Any idea?
thnx 4 help

Code: Select all

procedure TFoNew.ulozblob(id:string);
var

  Lstream: TStream;
begin
 OpenDialog1.Title := 'Načíst smlouvu...';
  if OpenDialog1.Execute then 
   begin

     OCAttachment.CreateObjectFromFile(opendialog1.FileName, False);
     dmmain.SQLCD101.Locate('id',id,[]);

     try
    	dmmain.SQLCD101.Edit;
       try

	   LStream := dmmain.SQLCD101.CreateBlobStream(dmmain.SQLCD101.FieldByName('priloha'),bmReadWrite);

           OCAttachment.SaveToStream(LStream);
           dmmain.SQLCD101.Post;
       except

       end;

     finally
    	OCAttachment.DestroyObject;
        Stream2.Free;
     end;
   end;
end;

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 06 Dec 2005 15:01

Please see BlobPictures demo for example.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 06 Dec 2005 15:01

Please see BlobPictures demo for example.

Post Reply