Recent

Author Topic: dataset is inactive  (Read 2978 times)

Roque

  • New Member
  • *
  • Posts: 11
dataset is inactive
« on: October 15, 2014, 05:29:59 pm »
previously i add a problem with mysql 5.5 / libmysql.dll couldn't be loaded 

Some one told me to put  that dll in root of project folder .. it works only at run time .. but it work´s

now .. can´t run a query the error says the dataset is inactive ...  it inactive because i can´t open/ active  de query

I get the message that the query is closed  and get the inactive error on SQLQuery1.First;   


procedure TForm1.Button1Click(Sender: TObject);
var
msg: String;
erro :Boolean;
begin
  erro:=false;
   msg:='ok ';
  MySQLConn.Connected:=true;
  if MySQLConn.Connected  then
     SQLTransaction1.Active:=true
  else
  begin
    erro:=true;
    msg:='MySQLConn not connected .!';
  end;

  if erro=false then
  begin
      if SQLTransaction1.Active then
        SQLQuery1.Active:=true
      else
      begin
       erro:=true;
       msg:='SQLTransaction1 not active .!';
         end;
  end;

  if erro=false then
  begin
      if not SQLQuery1.Active then
     begin
      erro:=true;
      msg:='SQLQuery1 not active ...!';
     end;
  end;

  if (erro) then
   MessageDlg('Error',msg ,mtError,[mbOK],0);


   SQLQuery1.First;
end; 

thank you
Roque

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1260
Re: dataset is inactive
« Reply #1 on: October 15, 2014, 07:16:13 pm »
Very odd.  Off the top of my head I cannot see any issue with your code...

Only difference between the code I use and yours is that I use SQLQuery.Open instead of SQLQuery.Active:=True;

I recently had this discussion about SQLTransaction.Active:=True verses SQLTransaction.StartTransaction, and was told then that they're the same. While the same is probably true about SQLQuery, make the change anyway, see what happens...

Only other thing I can suggest is have a poke around in Lazarus with the Form Designer and Object INspector.  Have you got all your Objects linked together correctly?
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines

paweld

  • Hero Member
  • *****
  • Posts: 991
Re: dataset is inactive
« Reply #2 on: October 15, 2014, 10:48:19 pm »
after the last IF statement, you must exit from procedure or insert SQLQuery1.First to the ELSE statement.
or use TRY EXCEPT block:
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
msg: String;
begin
  try
    msg:='MySQLConn not connected .!';
    MySQLConn.Connected:=true;
    msg:='SQLTransaction1 not active .!';
    SQLTransaction1.Active:=True;
    msg:='SQLQuery1 not active ...!';
    SQLQuery1.Active:=True;
    SQLQuery1.First;
  except
    MessageDlg('Error', msg, mtError, [mbOK], 0);
  end;
end; 
Best regards / Pozdrawiam
paweld

Roque

  • New Member
  • *
  • Posts: 11
Re: dataset is inactive
« Reply #3 on: October 17, 2014, 02:48:49 pm »
ok , thank you .. but in what way your tip helps me with the current problem ??

Roque

  • New Member
  • *
  • Posts: 11
Re: dataset is inactive
« Reply #4 on: October 17, 2014, 02:50:03 pm »
thank you ,

"Only other thing I can suggest is have a poke around in Lazarus with the Form Designer and Object INspector.  Have you got all your Objects linked together correctly?"

I will do that , thank you

 

TinyPortal © 2005-2018