One small note, you have an SQL injection at your code. I recommend
you to use parameters as how to add the values, but prior to that, you
should check to see if there are invalid chars, and trim them. That
way, you can avoid a lot of problems.

Ido

On Dec 12, 2007 1:54 AM, el stamatakos <[EMAIL PROTECTED]> 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
>



-- 
http://ik.homelinux.org/

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

Reply via email to