Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Blob field save AsString into DB (https://www.delphipraxis.net/176455-blob-field-save-asstring-into-db.html)

question 6. Sep 2013 07:57

Blob field save AsString into DB
 
Hi,
I have a Bolb field 'CollectID' in the DB and i am saving the data into this Blob Field AsString in the following way,
Code:
QueryA.ParamByName('CollectID').AsString := QueryB.FieldByName('CollectID').AsString;
its working fine,but i am not sure is that okay or it can be problem in future

Perlsau 6. Sep 2013 09:48

AW: Blob field save AsString into DB
 
What does this blob field represent? If you would fill a TMemo or a TRichEdit with the contents of this blob field, it would be okay. But if you want do represent a picture, a wave form or something like this it could be a problem to write/read it as string. Normally you read and write blob data by TFileStream or TMemoryStream:

Delphi-Quellcode:
function TDatMod.File_To_Blob(FileName: String; BlobFeld: TField): Boolean;
VAR
   S        : TStream;
   FileS    : TFileStream;

begin
     Result := FALSE;
     IF NOT FileExists(FileName) THEN EXIT;

     S     := BlobFeld.DataSet.CreateBlobStream(BlobFeld, bmReadWrite);
     TRY
        FileS := TFileStream.Create(FileName, fmOpenRead);
        S.CopyFrom(FileS, FileS.Size);
        Result := TRUE;
     FINALLY
        FileS.Free;
        S.Free;
     END;
end;

function TDatMod.Blob_To_File(FileName: String; BlobFeld: TField): Boolean;
VAR
   S        : TStream;
   FileS    : TFileStream;

begin
     Result := FALSE;
     IF BlobFeld.IsNull THEN EXIT;

     S := BlobFeld.DataSet.CreateBlobStream(BlobFeld, bmRead);
     TRY
        FileS := TFileStream.Create(FileName, fmCreate);
        FileS.CopyFrom(S, S.Size);
        Result  := TRUE;
     FINALLY
        S.Free;
        FileS.Free;
     END;
end;

question 6. Sep 2013 09:57

AW: Blob field save AsString into DB
 
it does not fill picture, it filled with binary text, in this situtation, is that okay to use it
Code:
QueryA.ParamByName('CollectID').AsString := QueryB.FieldByName('CollectID').AsString;
by the way, i have another problem, i have reinstalled the database and now the Blob field is not working in the whole application,dont know why,have you any suggestion?

DeddyH 6. Sep 2013 10:04

AW: Blob field save AsString into DB
 
Is the BLOB-field accessable using an administration-tool? If not, it is quite senseless to try to access it by your application and search for errors there.

question 6. Sep 2013 10:09

AW: Blob field save AsString into DB
 
Hi,
thanks for your important information
but there is no administration-tool to access the BLOB-field
in this situation,how can i overcome this problem?

DeddyH 6. Sep 2013 10:14

AW: Blob field save AsString into DB
 
Most administration-tools I know offer several options for BLOB-fields such as "view as text" or "view as picture". Maybe you have to search for them a little bit.

mkinzler 6. Sep 2013 10:22

AW: Blob field save AsString into DB
 
initiative of his/her own isn't questions kind. Thus he/she doesn't even try to understand answers and insits on his/her pov.

http://www.delphipraxis.net/176416-d...-new-post.html

@question If your solution works than be happy. We tried to told you several times that a blob isn't a normal field, and when you refuse to recognize it and not using an better solution than your easier but maybe buggy version, than do it on your own responsibility!


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:34 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz