Problem with ZEOS ZQuery lazarus / 16-Databases ---------------------------------------------------------------------- simonl · 2010-04-29 15:56 hello i been trying to exacute a command in zquery but i keep getting index out of bounds message my code is as follows Code: [Select]   ZQuery1.SQL.Text := 'SELECT count(*) FROM groups,rooms WHERE groups.n=rooms.id and groups.n=' + LobbysTable.FieldByName('n').AsString;    ZQuery1.ExecSQL;    ZQuery1.Open; i get the error with Code: [Select]ZQuery1.Params[0].AsString am trying to get counts of all rooms in each of my lobbys! can sumone help me pin point problem cheers ---------------------------------------------------------------------- fredycc · 2010-04-29 17:04 hi, I use Zeos too, this is an example, how to use params, and how you can pass any other data from another query and how retrieve Id('SELECT @@IDENTITY AS IdTransaccion'  <- just works for MS sql server). Qry2.SQL.Add ('insert into PdaPagoHeader (Modulo,TipoCliente,CodUsuari o,FechaReunion,MonTotal,CodPrestamo,IdTranPDA,Status) ');                 Qry2.SQL.Add ('values (:Modulo,:TipoCliente,:CodUsuari o,:FechaReunion,:MonTotal,:CodPrestamo,:IdTranPDA,:Status) ');                 Qry2.SQL.Add ('SELECT @@IDENTITY AS IdTransaccion ');                 Qry2.ParamByName('Modulo').AsString := 'PAGO';                 Qry2.ParamByName('TipoCliente').AsString := 'G';                 Qry2.ParamByName('CodUsuario').AsString := Qry1.FieldByName('CodGrupo').AsString;                 Qry2.ParamByName('FechaReunion').AsDateTime := Now;                 Qry2.ParamByName('MonTotal').AsCurrency := Qry1.FieldByName('Total').AsCurrency;                 Qry2.ParamByName('CodPrestamo').AsString := Qry1.FieldByName('CodPrestamo').AsString;                 Qry2.ParamByName('IdTranPDA').AsString := FileName;                 Qry2.ParamByName('Status').AsString := 'OK'; ---------------------------------------------------------------------- Zoran · 2010-04-29 17:32 Quote from: simonl on April 29, 2010, 05:56:50 pmhello i been trying to exacute a command in zquery but i keep getting index out of bounds message my code is as follows Code: [Select]   ZQuery1.SQL.Text := 'SELECT count(*) FROM groups,rooms WHERE groups.n=rooms.id and groups.n=' + LobbysTable.FieldByName('n').AsString;    ZQuery1.ExecSQL;    ZQuery1.Open; i get the error with Code: [Select]ZQuery1.Params[0].AsString am trying to get counts of all rooms in each of my lobbys! can sumone help me pin point problem cheers Your ZQuery1 has NO parameters. The parameters are given with colon ( : ) prefix. If you had written Code: [Select]SELECT count(*) FROM groups,rooms WHERE groups.n=rooms.id and groups.n = :n then ZQuery1 would have had one parameter named n and you would have been able to use for example Code: [Select]ZQuery1.ParamByName('n').AsString := LobbysTable.FieldByName('n').AsString;or (which does the same) Code: [Select]ZQuery1.Params[0].AsString := LobbysTable.FieldByName('n').AsString; And this is provided groups.n is string field. If it is of type integer, you should use .AsInteger instead. ---------------------------------------------------------------------- Zoran · 2010-04-29 17:42 If you actually want to read field value, then you should just use Fields[0] instead of params[0].