Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with BLOB FieldType

Status
Not open for further replies.

bon011

Programmer
Jun 2, 2002
155
CZ
Hi all,

Does anybody know how to read data from tableField that is BLOB binary FieldType??
Data should be in this structure that was create in DELPHI.

s_type: CHAR
s_num: STRING[12]
s_no: REAL

AND ther can be more than one structure in this field.
Table is Paradox v 7.0 create in Dalphi 6.0. I wont to read it in C++Builder v 5.0

Thanks
 
Hi :)

You can use Streams to read the blob field.Here is some text from C++Builder Help:

TBlobField::SaveToStream

Saves the contents of the BLOB field to a stream.

void __fastcall SaveToStream(Classes::TStream* Stream);

Description

Use SaveToStream to copy the contents of a BLOB field to a stream. Specify the name of the stream to which the field’s value is saved as the value of the Stream parameter.

Note: The Stream parameter is typically not a BLOB stream. BLOB streams (returned by the dataset’s CreateBlobStream method) provide a completely separate mechanism for streaming data from a BLOB field.

TMemoryStream *pMS = new TMemoryStream;
try
{
SQLDataSet1Images->SaveToStream(pMS);
Image1->Picture->Bitmap->LoadFromStream(pMS);
}
__finally
{
delete pMS;
}



TBlobField::LoadFromStream

Loads BLOB data from a stream into the field.

void __fastcall LoadFromStream(Classes::TStream* Stream);

Description

Use LoadFromStream to copy the contents of a stream into the BLOB field. Specify the stream from which the field’s value is copied as the value of the Stream parameter.

Note: The Stream parameter is typically not a BLOB stream. BLOB streams (returned by the dataset’s CreateBlobStream method) provide a completely separate mechanism for streaming data into a BLOB field.

if ((ClientDataSet1->State != dsInsert) &&
(ClientDataSet1->State != dsEdit))
ClientDataSet1->Insert();

TMemoryStream *pMS = new TMemoryStream;
try
{
Image1->Picture->Bitmap->SaveToStream(pMS);
ClientDataSet1Images->LoadFromStream(pMS);
}
__finally
{
delete pMS;
}
ClientDataSet1->Post();
 
Cant you use a DBMemo or a DBImage and get the blob from the table directly loaded to the object.

or to load from a file and insert to a table -
DBImage1->Picture->LoadFromFile(OpenDialog1->FileName);
post ();

But then I dont't think the blobs that
are in question are as simple as a text or graphic.

BlobString = MyBLOBField->AsString;

From the help file.
-------------------------------------------
Typically, using AsString makes sense only if the BLOB contains text, such as that in a memo field component. The AnsiString type can, however, store binary data as well. Thus, even BLOB fields for nontextual BLOB types such as ftGraphic or ftTypedBinary can use the AsString property.
-------------------------------------------

you might test the blob for type first. Ill bet the
answers are in the TBlobField Help.

I'm oversymplyfying again. sorry.

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top