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:
pFilename:='D:/test.jpg';
form1.SQLQuery7.SQL.Text := 'update maindata set org_logo = :org_logo where id = :ID';
form1.SQLQuery7.Params.ParamByName('id').Value:=form1.SQLQuery1.FieldValues['ID'];
form1.SQLQuery7.Params.ParamByName('org_logo').LoadFromFile(pFileName,ftBlob);
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....
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:
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