Problem with BLOB fields

Code samples and contributions from users for ZeosLib's DBOs of version 6.x

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Anton7
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 29.09.2006, 00:39

Problem with BLOB fields

Postby Anton7 » 05.11.2006, 14:03

How i can insert data in blob field?
next code doesn`t work correct:

Code: Select all

    TStream *Stream2;
    Form2->ZQ2->Insert();
    Stream2 = Form2->ZQ2->CreateBlobStream(Form2->ZQ2->FieldByName("Question"), bmWrite);
    Form2->ZQ2->FieldByName("Question_id")->AsInteger=a;
    Stream2->Write("lalalala",8);
//or Stream2->CopyFrom(..........);
    Form2->ZQ2->Post();
Field "Question_id" have value, but Field "Question" is empty!!!

But code:

Code: Select all

    TStream *Stream2;
    Form2->ZQ2->Insert();
    Form2->ZQ2->FieldByName("Question_id")->AsInteger=a;
    Form2->ZQ2->FieldByName("Question")->AsString="lalalala";
    Form2->ZQ2->Post();
work correct.

I work in C++Builder6 with embedded MySQL 4.1 and ZEOSLIB(rev 113)

PLEASE HELP!!!

martinrame
Junior Boarder
Junior Boarder
Posts: 25
Joined: 24.10.2006, 18:29
Location: Córdoba, Argentina
Contact:

Postby martinrame » 09.11.2006, 18:53

I'm not a C++ developer, but i'll try to help you.

First, replace the TZTables with TZQuery.

Add the insert SQL sentence into the SQL->Text field of TZQuery:

Code: Select all

myQuery->Sql->Text := "Insert into TABLE(IdQuestion, Question) values(:idquestion, :question)";

Now assign the parameters (:idquestion and :question)

// assign a value to idquestion
myQuery->ParamByName("idquestion").AsInteger = a; // a is an integer

// this adds a stream into the param question
// (of course Stream2 must be initialized and contain data)
myQuery->ParamByName("question").LoadFromStream(Stram2, ftBlob);

// exec query
myQuery->ExecSql;

martinrame
Junior Boarder
Junior Boarder
Posts: 25
Joined: 24.10.2006, 18:29
Location: Córdoba, Argentina
Contact:

Postby martinrame » 09.11.2006, 18:55

P.S.: The dots must be replaced with -> (i'm Delphi developer)

Anton7
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 29.09.2006, 00:39

Postby Anton7 » 23.11.2006, 23:55

Sorry, i could not answer earlier.
Only this code workes correctly:

Code: Select all

((TBlobField*)Form2->ZQ2->FieldByName("Question"))->LoadFromStream(str1);


Return to “User Contributions”

Who is online

Users browsing this forum: No registered users and 1 guest