0

I have a Firbird 1.0 data file weighting aprox 25 GB that I am working with it. It has a table which has stored documents and doc's pics as blob. So, I am asking is it possible to open such big data file using fib datasets, i firstly tried to open dataset in runtime = no success as grid was empty so another try was to set it active in design mode which it was also unable to open as it's active property is set to true but no fetched data in grid!

Have you any idea to make it work ? Do I have to set any blob cashe options? or it is not possible at all?

Now I am developing using my laptop computer (Win 7 x64 4GB Ram ), and later it'll be deployed to my server machine!

I've fixed it!

So another my question is about loading blob data using stream to a TImage component

i am doing like this but it pops out an Access violation

here is my code which you may look at

    DM->stImage->Active=true;
    try {
        TMemoryStream *ms=new TMemoryStream();
        TStream *ps=DM->stImage->CreateBlobStream(DM->stImage->FieldByName("PHOTO") ,bmRead);
        ms->Position=0;
        ms->CopyFrom(ps,ps->Size);
        ms->SaveToFile("c:\\1.jpg");
//      imgPass->Picture->LoadFromStream(ms);
        imgPass->Picture->Graphic->LoadFromStream(ps);
        delete ms;
        delete ps;
    }
    catch (Exception &e) {
        ShowMessage(e.ToString());
    }

it can save it but imgPass->Picture->Graphic->LoadFromStream(ps); does not work! what could be a problem?

Suhrob Samiev
  • 1,478
  • 1
  • 24
  • 55

1 Answers1

0

To avoid the AV you need to reset the stream position, that was moved forward during the call to "CopyFrom" function.

So, your code should look like (only the relevant lines):

ms->CopyFrom(ps,ps->Size);
ms->SaveToFile("c:\\1.jpg");
ps->Position = 0; //<<<<<<<<<< here we reset the stream position
imgPass->Picture->Graphic->LoadFromStream(ps);
//imgPass->Picture->Bitmap->LoadFromStream(ps); // <<< if a bitmap and not JPEG

Hope this helps you.

P.S.: this question should be tagged C++ (or C++Builder) because it is not only a database subject.

jfoliveira
  • 2,056
  • 11
  • 23