воскресенье, 4 декабря 2011 г.

Недавно писал Мартину.



Set the select statement ("SQL" property = "select * from table1"), the insert, delete and update statements are built automatically. Then use tmsesqlquery.edit(), insert(), delete() and post() or cancel() and access the fields. In order to write the data to the server call tmsesqlquery.applyupdates(). In order to commit call tmsesqltransaction.commit() or commitretaining(). applyupdates() will be called automatically after post() if tmsesqlquery.controller.options dso_autoapply is set. commitretaining() will be called automatically after applyupdates if dso_autocommitret is set. commit() will be called automatically after applyupdates if dso_autocommit is set. Martin
Проще говоря у меня не работала загрузка данных в blob:
queryW:=tmsesqlquery.Create (nil);
queryW.Database:=con;
queryW.Transaction:=writetran;
queryW.StatementType:=stUpdate;
queryW.SQL:=UPDCONTEST;//UPDCONTEST is correct and given before
queryW.Prepare;   
queryW.params.ParamByName ('pNAME').AsString:=name.text;
queryW.params.ParamByName ('pABOUT').AsBlob:=about;
queryW.params.ParamByName ('pLOGO').AsBlob:=img;
queryW.params.ParamByName ('pID').AsInteger:=ID; 
queryW.ExecSQL;
writetran.commit;

Оказалось, что blob в firebird передается по специальному протоколу. Я спросил: "Может мне использовать CreateBlobStream", в ответ мне пришло загадочное сообщение: "А может использовать tmsesqlquery". Я призадумался. В голову по этому поводу так и не пришли мысли, поэтому я сказал прямо: "А как использовать tmsesqlquery?"В ответ Мартин написал эпичнейшее описание, с которого начинается эта запись в моем блоге. Описание работы с tmsesqlquery в mseide. Это просто и удобно:
  • query.sql.settext (select* from table1); //Это нужно чтобы выбрать записи и столбцы для работы. Скрипты для вставки в это таблицу, обновления записей и удаления генерируются автоматически.
  • Использовать методы tmsesqlquery.edit(), tmsesqlquery.insert(), tmsesqlquery.delete(), tmsesqlquery.post() или tmsesqlquery.cancel() для работы с выбранными полями.
  • ВСЕ! И никаких CreateBlobStream или подобного маразма!
Скажем дружно Мартину спасибо за это! =)

Комментариев нет:

Отправить комментарий