title: Database error - cursor not returned from query
body: <p>Had an issue with "cursor not returned from query" and found a solution that basicaly reopens the query once more:</p>
  
  <pre><code>procedure TForm2.AdvGlowButton1Click(Sender: TObject);
  begin
  with ClientdataSet1 do
  begin
  Close;
  CommandText :='';
  CommandText :='INSERT INTO TLOG (LOKACIJA_ID,OPOMBA) VALUES (:a1,:a2)';
  Params.ParamByName('a1').Value :=  Form3.ClientDataSet4.FieldByName('LOKACIJA_ID').AsString;
  Params.ParamByName('a2').Value := cxMemo1.Text;
  Execute;
  CommandText :='';
  CommandText :='SELECT * FROM TLOG WHERE LOKACIJA_ID =:a1';
  Params.ParamByName('a1').Value := Form3.ClientDataSet4.FieldByName('LOKACIJA_ID').AsString;
  Open;
  end;
  </code></pre>
  
  <p>Now,I am wondering if this is the right approach or is there another way around this error? If I try and open the dataset after first execute (delete the rest)I get the mentioned error. Is this the way this is supposed to function? This is a datasnap client-server app with sqlite as backend DB.</p>
  
  <p>edit:
  The form with the dataset1 that runs this query uses another form (form3) i.e it's Form3.DSProviderConnection1 to connect to server.On the server side in ServerMethodsUnit1
  I have a DatasetProvider8 which is linked to SQLQuery7 (in the SQL of the query I have: select * from TLOG). I suppose I could replace this query on the server with a table.Now,what I am doing is this on the FormShow :</p>
  
  <pre><code>procedure TForm2.FormShow(Sender: TObject);
  begin
  with ClientdataSet1 do
  begin
  ClientdataSet1.Close;
  ClientdataSet1.CommandText :='';
  ClientdataSet1.CommandText :='SELECT * FROM TLOG WHERE LOKACIJA_ID =:a1';
  ClientDataSet1.Params.ParamByName('a1').Value := Form3.ClientDataSet4.FieldByName('LOKACIJA_ID').AsString;
  ClientDataSet1.Open;
  end; 
  </code></pre>
  
  <p>I am fetching records based on the location. So now the user sees only the records from his location in the grid.So if I am not mistaken if user adds or changes a record the data first must be inserted and then displayed again in the same manner it was fetched. Or no ? Or perhaps it would be better to replace that server query with a table and display the table itself with a filter (location_id) so I could just run insert query and just call Table refresh?</p>