Buen dia .. tengo un detalle .... anterior mente usaba el siguiente código con el componente Query y me funcionaba muy bien sin problemas, usando en aquel entonces tablas paradox..
Código PHP:
with QueryRegONT do // Busqueda por Modelo y Tipo
begin
Close;
SQL.Clear;
// ------------------------------------------------------------
// Se ultilizó el PArametro JOIN para unir las otras Tablas
// relacionando el Campo FOLIO en todas ellas siempre y cuando
// Se cumpliera la condicion de busqueda del ONT ya registrado.
// ------------------------------------------------------------
SQL.Add('SELECT * FROM CTRLONT.db CTRL ');
SQL.Add('join CLIENTES.db CL on CTRL.FOLIO = CL.FOLIO ');
SQL.Add('join ONT.db ONT on CTRL.FOLIO = ONT.Folio ');
SQL.Add('WHERE BOARD_ONT=:BOARD_ONT');
SQL.Add(' AND FRAME_ID=:FRAME_ID');
SQL.Add(' AND SLOT_ID=:SLOT_ID');
SQL.Add(' AND PORT_ID=:PORT_ID');
SQL.Add(' AND ONT_ID=:ONT_ID');
// --------------------------------------------------------
// Valores de búsqueda para el registro de Cliente.
// --------------------------------------------------------
ParamByName('BOARD_ONT').AsInteger := StrToInt(Edit1.Text);
ParamByName('FRAME_ID').AsInteger := StrToInt(Edit2.Text);
ParamByName('SLOT_ID').AsInteger := StrToInt(Edit3.Text);
ParamByName('PORT_ID').AsInteger := StrToInt(Edit4.Text);
ParamByName('ONT_ID').AsInteger := StrToInt(Edit5.Text);
Open;
if QueryRegONT.IsEmpty then
Begin
msError('El ONT no se encuentra registrado, porfavor verifica los datos.','No existe Datos..');
exit;
End
Else
Begin
F:= QueryRegONT.FieldByName('FOLIO').AsInteger;
// -------------------
with QueryCL do // Busqueda por Modelo y Tipo
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM CLIENTES.db ');
SQL.Add('WHERE FOLIO=:FOLIO');
ParamByName('FOLIO').AsInteger :=F;
Open;
end;
with QueryONT do // Busqueda por Modelo y Tipo
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM ONT.db ');
SQL.Add('WHERE FOLIO=:FOLIO');
ParamByName('FOLIO').AsInteger :=F;
Open;
end;
// -------------------
Bok.Enabled := True;
BBuscar.Enabled := False;
DesactivarCampos([Edit1,Edit2,Edit3,Edit4,Edit5]);
End;
end;
Ahora el mismo código lo intenté migrar al componente ADOQuery ya que ahora estoy trabajando con tablas Mysql y lo tengo de esta forma:
Código PHP:
with ADOQueryCtrlONT do // Busqueda por Modelo y Tipo
begin
Close;
SQL.Clear;
// ------------------------------------------------------------
// Se ultilizó el PArametro JOIN para unir las otras Tablas
// relacionando el Campo FOLIO en todas ellas siempre y cuando
// Se cumpliera la condicion de busqueda del ONT ya registrado.
// ------------------------------------------------------------
SQL.Add('SELECT * FROM CTRLONT CTRL ');
SQL.Add('join CLIENTES CL on CTRL.FOLIO = CL.FOLIO ');
SQL.Add('join ONTs ONT on CTRL.FOLIO = ONT.Folio ');
SQL.Add('WHERE BOARD_ONT= :BOARD_ONT');
SQL.Add(' AND FRAME_ID= :FRAME_ID');
SQL.Add(' AND SLOT_ID= :SLOT_ID');
SQL.Add(' AND PORT_ID= :PORT_ID');
SQL.Add(' AND ONT_ID= :ONT_ID');
// --------------------------------------------------------
// Valores de búsqueda para el registro de Cliente.
// --------------------------------------------------------
Parameters.ParamByName('BOARD_ONT').Value := Edit1.Text;
Parameters.ParamByName('FRAME_ID').Value := Edit2.Text;
Parameters.ParamByName('SLOT_ID').Value := Edit3.Text;
Parameters.ParamByName('PORT_ID').Value := Edit4.Text;
Parameters.ParamByName('ONT_ID').Value := StrToInt(Edit5.Text);
Open;
if ADOQueryCtrlONT.IsEmpty then
Begin
msError('El ONT no se encuentra registrado, por favor verifica los datos.','No existe Datos..');
exit;
End
Else
Begin
F:= ADOQueryCtrlONT.FieldByName('FOLIO').Value;
// -------------------
with ADOQueryCL do // Busqueda por Modelo y Tipo
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM CLIENTES ');
SQL.Add('WHERE FOLIO= :FOLIO');
Parameters.ParamByName('FOLIO').Value :=F;
Open;
end;
with ADOQueryONT do // Busqueda por Modelo y Tipo
begin
Close;
SQL.Clear;
SQL.Add('SELECT * FROM ONTs ');
SQL.Add('WHERE FOLIO= :FOLIO');
Parameters.ParamByName('FOLIO').Value :=F;
Open;
end;
// -------------------
Bok.Enabled := True;
BBuscar.Enabled := False;
DesactivarCampos([Edit1,Edit2,Edit3,Edit4,Edit5]);
End;
end;
Al ejecutarlo me marca un mensaje de error que dices asi:
"Argumentos incorrectos, fuera del intervalo permitido o en conflicto con otro"
El compilador no marca error y prácticamente estoy usando el mismo código con el que si me funcionaba, saben cual podría ser el error?
EL error del mensaje lo genera en esta línea:
Código PHP:
SQL.Add('WHERE BOARD_ONT=:BOARD_ONT');