Problem using bookmarks lazarus / 16-Databases ---------------------------------------------------------------------- daveinhull · 2017-09-20 19:20 Hi, I'm struggling a little over using TSQLQuery and I'm hoping someone can point me in the right direction. I've got SQLQuery fully working through Obective Inspector and I can do all the normal activities with it using the Navigation bar. However I want to add a picture to the main table pointed to by SQLQuery. I'm suing the following code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   pFilename:='D:/test.jpg';  form1.SQLQuery7.SQL.Text := 'update maindata set org_logo = :org_logo where id = :ID';  form1.SQLQuery7.Pa rams.ParamByName('id').Value:=form1.SQLQuery1.FieldValues['ID'];  form 1.SQLQuery7.Params.ParamByName('org_logo').LoadFromFile(pFileName,ftBl ob);  form1.SQLQuery7.ExecSQL; Which works fine on the press of a button. However, it doesn't show on the form's DBImage linked to the org_logo that is updated above. So I use.... Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   form1.SQLTransaction1.CommitRetaining;  form1.SQLQuery1.Refresh; ....to refresh the maindata form and it does show the picture. However, when I do this the main record set (SQLQuery) goes back to the first record (as would be expected) and I want it to stay on the record I've added the picture to. I have tried many things, but I thought I'd just save my stress levels and ask how it would be best done. I tried using TBookMark to save where I was before and then restore after as in: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   bmCurrentRecord:=Form1.SQLQuery1.GetBookmark ;  form1.SQLTransaction1.CommitRetaining;  form1.SQLQuery1.Refresh;  form1.SQLQuery1.GotoBookmark (bmCurrentRecord); But this works the first time on the first record, but crashes with an exception at any other time. I also tried looking for a .GotoReocrd, or a .Find=??? or something that I could use to go to a particular record, but can see anything unless I'm completely missing it. Alternatively, a method for saving the picture in the table and then showing it on the current form view. Any help would be really appreciated. Many thanks in advance Dave ---------------------------------------------------------------------- daveinhull · 2017-09-20 20:01 Hi, Ok, I've found .Locate which does the job, but it would be good to understand why the .Bookmark approach didn't work, i.e. what might case the exception to be raised. Thanks Dave ---------------------------------------------------------------------- taazz · 2017-09-20 20:08 To put it the simplest way I can, a bookmark is a pointer to the record's data in memory. By calling refresh you deallocate the current memory and re query the results from the server. Any bookmark that you had saved before the refresh call is now invalid and needs to be discarded. ---------------------------------------------------------------------- daveinhull · 2017-09-20 20:19 Thanks taazz for taking the time to get back to me, and yes of course that makes complete sense and in the back of my mind I was felling that it was to do with the .refresh.