Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Conexión con bases de datos (https://www.clubdelphi.com/foros/forumdisplay.php?f=2)
-   -   Tengo Duda de como usar ZTTable para MySQL (https://www.clubdelphi.com/foros/showthread.php?t=60144)

foxito 22-09-2008 15:44:44

Tengo Duda de como usar ZTTable para MySQL
 
Hola lista

Tengo duda de como usar ZTTable cuando en un Formulario tengo un ZTQuery y ZTTable, el QUERY lo uso para mostrar en rejillas mi consulta y ZTTable para grabar en mi tabla, pero cuando busco en ZTQuery tambien busco en ZTTable para que ambos esten actualizados.

¿Mi pregunta es la siguiente con un solo objeto puedo hacer las 2 cosas?

Porque tengo Query y Table porque en el QUERY HAGO QUE MUESTRE EN BASE A UN CAMPO OTRA COSA. POR EJEMPLO

AQUI ESTA COMO CONSULTO
Código SQL [-]
size="1">SELECT Nombre,
CASE WHEN Nivel = 1 THEN 'Grupo' ELSE 'SubGrupo' 
END AS Nivel2,Id
FROM Lineas

AQUI COMO BUSCO

Código Delphi [-]
procedure TFrmLineas.bOkClick(Sender: TObject);
begin
  begin
    if EdFind.Text = '' then
    begin
      ShowMessage('Debe escribir un texto para realizar la búsqueda');
      EdFind.SetFocus;
    end
    else
    begin
      if qLineas.Locate('NOMBRE', EdFind.Text, [loCaseInsensitive, loPartialKey]) then
      begin
        tLineas.Locate('NOMBRE', EdFind.Text, [loCaseInsensitive, loPartialKey]);
        DBGrid.SetFocus;
      end
      else
        ShowMessage('No se encuentra ninguna linea con esa descripción');
        EdFind.Text := '';
        EdFind.Enabled := False;
        bOk.Enabled := False;
        bNew.Enabled := True;
        bEdit.Enabled := True;
        bDelete.Enabled := True;
      end;
  end;
end;

AQUI GRABO

Código Delphi [-]
procedure TFrmLineas.bAceptarClick(Sender: TObject);
var
cDes : String;
begin
  if GestionNuevo then
    begin
      tLineas.Close;
      tLineas.Open;
      tLineas.Insert;
      //ZTLineasID.AsInteger := Id;
      tLineasNombre.AsString := EdLinea.Text;
      tLineasNivel.AsInteger := rdNivel.ItemIndex + 1;
      tLineas.Post;
      cDes := EdLinea.Text;
      RefrescarLineas(cDes);
      CerrarEdicion;
    end
  else  { not GestionNuevo -> Editando existente }
  begin
    cDes := EdLinea.Text;
    tLineas.Edit;
    tLineasNOMBRE.AsString := EdLinea.Text;
    tLineasNivel.AsInteger := RdNivel.ItemIndex;
    tLineas.Post;
    RefrescarLineas(cDes);
    CerrarEdicion;
  end;
end;

mightydragonlor 22-09-2008 15:50:48

Hola foxito, este hilo ya lo creaste, no por que tengas n hilos iguales significa que te van a responder mas rápido, ademas si quieres reactivar el hilo solo tienes que comentar sobre el ya creado, es mejor que tengas cuantas la guia de estilo, ademas creo que pronto cerrarán este hilo por incumplir con las directivas del foro.


La franja horaria es GMT +2. Ahora son las 14:50:55.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi