![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
#1
|
|||
|
|||
|
ayuda excepciones
Buenos días, perdon pero estoy comenzando con delphi, y las excepciones no las tengo muy claras, el problema es q no se en que estoy fallando, y siempre me genra este error,-...
Project bas.exe raised exception class EIBInterBaseError with message 'violatio of PRIMARY or KEY UNIQUE constraint "PK_AGENDA" ......... Si alguien me puede ayudar y decir como hago para que la excepcion o me frene el programa y continue ya que si la llave esta duplicada no debe cargarlo y nada mas,, muchas gracia spor la ayuda.. var Form1: TForm1; f : TextFile; Nom,Dir,Ciu,Tel,rec1,u,s,trama: AnsiString; a,rec: Integer; cadena,re,sLinea: String; i: Integer; implementation uses base; {$R *.dfm} procedure TForm1.Botton1Click(Sender: TObject); begin AssignFile (f,'c:\bases\base.txt'); Reset (f); Readln(f,cadena); CloseFile (f); re:=AnsiMidStr(cadena, 7, 8); TrimRight( re); i:= StrToInt(re); while FileExists ('c:\bases\'+cadena+'.txt') do begin if FileExists('c:\bases\'+cadena+'.txt') then begin AssignFile (f,'c:\bases\'+cadena+'.txt'); Reset (f); while not Eof( F ) do begin ReadLn( F, sLinea ); trama:=sLinea; Rec1:=AnsiMidStr(trama, 1, 8); Nom:=AnsiMidStr(trama, 9, 10); Dir:=AnsiMidStr(trama, 19, 10); Ciu:=AnsiMidStr(trama, 29, 10) ; Tel:=AnsiMidStr(trama, 39, 10) ; u := StringReplace(Rec1, ' ', '', [rfReplaceAll]); TrimRight(u); Form1.IBTable1.Insert; // Ponemos la tabla en modo insercion Form1.IBTable1.FieldbyName('Recibo').AsInteger := StrToInt(u); Form1.IBTable1.FieldbyName('Nombre').AsString := Nom; // Form1.IBTable1.FieldbyName('Direccion').AsString := Dir; // Form1.IBTable1.FieldbyName('Ciudad').AsString := Ciu; // Insertamos Form1.IBTable1.FieldbyName('Telefono').AsString := Tel; // try Form1.IBTable1.Post; // Guardamos los cambios. except on E: EIBInterBaseError do begin case E.IBErrorCode of 335544665: else raise; end; end; end; //************************************ end; CloseFile (f); //************************************* i:=i+1; AssignFile (f,'c:\bases\base.txt'); Rewrite( F ); WriteLn(f,'nombre'+IntToStr(i)); CloseFile (f); end else //if begin ShowMessage('No hay datos para cargar'); close; end; //******************************************** AssignFile (f,'c:\bases\base.txt'); Reset (f); Readln(f,cadena); CloseFile (f); end; //******************************************** end; procedure TForm1.Button5Click(Sender: TObject); begin close end; end. |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| Duda Sobre Excepciones - Propagar Excepciones entre los formularios | Neeruu | Varios | 2 | 26-02-2010 20:36:50 |
| Excepciones | adpa | OOP | 5 | 14-12-2005 15:45:45 |
| Excepciones | Acker | Tablas planas | 6 | 06-08-2005 15:22:18 |
| excepciones!!!!! | hanna33 | OOP | 3 | 24-05-2005 17:10:10 |
| Ayuda con Manejo de Excepciones | buffygcs | SQL | 2 | 21-04-2005 17:52:09 |
|