save picture in database

save picture in database

Post by Ayman Hann » Fri, 22 Jun 2007 06:12:55


Hello community,

I woul like to save a picture in database and then get it - using ODBC.
I used the following code, but the get is not working:

mpPackage->mpDBQueryConn->pDataBase->StartTransaction();
mpPackage->mpDBQueryConn->pQuery->Close();
mpPackage->mpDBQueryConn->pQuery->SQL->Clear();
mpPackage->mpDBQueryConn->pQuery->SQL->Add("insert into pic values (:image,
1)");
mpPackage->mpDBQueryConn->pQuery->ParamByName("image")->SetBlobData(Image3->Picture,
10);
mpPackage->mpDBQueryConn->pQuery->ExecSQL();
mpPackage->mpDBQueryConn->pDataBase->Commit();

mpPackage->mpDBQueryConn->pQuery->Close();
mpPackage->mpDBQueryConn->pQuery->SQL->Clear();
mpPackage->mpDBQueryConn->pQuery->SQL->Add("select pic from pic");
mpPackage->mpDBQueryConn->pQuery->Open();
Image11->Picture =
(TPicture*)(mpPackage->mpDBQueryConn->pQuery->FieldValues["pic"].VUnknown);

While mpPackage->mpDBQueryConn->pQuery is a TQuery.

insert work fine, but I cannot do the select...
Did i use the right way???
Please advice

Best regards,
Ayman