Hi Lefti,

Opening and closing the query causes the query to be re-parsed and prepared. IF you change the sql text, there is no way round this. At the very least, prepare has to be called, and opening a query does not do a lot more than calling prepare. From what I can see in the code, to prepare a query, you have to un-prepare the previous one, and that fails unless the query is closed.

By the way, when you start a new topic, you are setting a new subject, but still replying to a previous topic. Any threaded mail client still sees it as a reply to a previous topic, and makes a real mess of a threaded view! According to my email, this is still part of a discussion that started with "[lazarus] Patch for Forms in Forms or MDI" Could you send a new message, not a reply, with a new subject ?

cheers,
John Sunderland

el stamatakos wrote:
Hi All,
 I have an application that connects to a MySQl database. I have found the only way to 
get Lazrus to work without giving me an error "Cannot access Active DataSet" is 
to do a Clear,Add, Open Close, like below

MainForm.SQLQuery1.SQL.Clear;

MainForm.SQLQuery1.SQL.Add('SELECT revID from rev WHERE 
revName='+#39+CBProcessRev.Text+#39);


MainForm.SQLQuery1.Open;

if MainForm.SQLQuery1.SQL.Text<>'' then
 if MainForm.SQLQuery1.RecordCount>0 then
    revID:=MainForm.SQLQuery1.FieldValues['revID'];
   // showmessage(IntToStr(revID));

MainForm.SQLQuery1.Close;

MainForm.SQLQuery1.SQL.Clear;

MainForm.SQLQuery1.SQL.Add('SELECT * from flow WHERE 
processID='+IntToStr(ProcessID)+
' AND '+IntToStr(revID)+'='+IntToStr(revID));

MainForm.SQLQuery1.Open;

if MainForm.SQLQuery1.SQL.Text<>'' then
 while Not MainForm.SQLQuery1.EOF do begin
 CBProcessFlow.Items.Add(MainForm.SQLQuery1.FieldValues['flowName']);
 MainForm.SQLQuery1.Next;
 end;

MainForm.SQLQuery1.Close;

My Question is why do I have to close and re open is there a better way of 
doing this. Thanks

Lefti
_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to