Ver Mensaje Individual
  #1  
Antiguo 12-08-2010
MikyVato MikyVato is offline
Miembro
 
Registrado: mar 2005
Posts: 39
Reputación: 0
MikyVato Va por buen camino
Red face Excepción en conexión MySQL

Hola amigos, tengo un pequeño problema, hice una aplicacion en Delphi que se conecta con un servidor de DB MySQL el cual se encuentra en un Hosting, quiero poner una excepción al código en caso de que la conexión a internet falle pero no me toma estas excepciones aqui les dejo el codigo espero puedan ayudarme. Desde ya gracias...

Código:
begin
  //obtengo el ultimo ID da la tabla externa
  idlocal := '0';
  QidExterno.Active := False;
  QidExterno.SQL.Clear;
  QidExterno.SQL.Text := 'select * from cliente order by id desc';
  try
    QidExterno.Active := True;
    idlocal := QidExterno.Fields[0].AsString;
  finally
    //obtengo los registros pendientes de subir de la Tabla Local
    if StrToInt (idlocal) <> 0 then
      begin
        QPrincipal.Active := False;
        QPrincipal.SQL.Clear;
        QPrincipal.SQL.Text := 'select * from cliente where id > '''+idlocal+'''';
        QPrincipal.Active := True;

        while (not QPrincipal.Eof) do
          begin
            idlocal := QPrincipal.Fields[0].AsString;
            nom := QPrincipal.Fields[1].AsString;
            loc := QPrincipal.Fields[2].AsString;
            try
              QInsercion.SQL.Clear;
              QInsercion.SQL.Text := 'INSERT INTO cliente (Id,nombre,localidad) VALUES ('''+idlocal+''','''+nom+''','''+loc+''')';
              QInsercion.ExecSQL;
            finally
              QPrincipal.Next;
              LTiempo.Caption := ' '+DateToStr (Date)+'  '+TimeToStr (Time)+'';
            end;
          end;
      end
    else
      LTiempo.Caption := 'No se subieron datos!!';
  end;
end;
Puntualmente no me funcionan las estruturas

Código:
try
   //instrucciones
except
   //instrucciones
end;
como tampoco la estructura

Código:
try
   //instrucciones
finally
   //instrucciones
end;
Responder Con Cita