FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
Erro extraño al insertar registro
hola amigos miren aquie con un problema...cuando inserto un nui¿evo registro me mando error que segun hay un error con la llave primaria (duplicado) aunque no es verdad. aunque al final lo siempre si guarda el registro aqui dejo el codigo:::
procedure TFrmEmpleados.BtnGuardarClick(Sender: TObject); var global : integer; begin global :=0; if CmbDireccion.Text='' then begin global:=1; CmbDireccion.color:=clInactiveCaptionText; end; //........................................................ if EdNumEmpleado.Text='' then begin global:=1; EdNumEmpleado.color:=clInactiveCaptionText; end; //............................. if Ednombre.Text='' then begin global:=1; Ednombre.color:=clInactiveCaptionText; end; //............................ if EdAppaterno.Text='' then begin global:=1; EdAppaterno.color:=clInactiveCaptionText; end; //............................ if EdApmaterno.Text='' then begin global:=1; EdApmaterno.color:=clInactiveCaptionText; end; //............................ if EdNivel.Text='' then begin global:=1; EdNivel.color:=clInactiveCaptionText; end; //............................ if EdLogin.Text='' then begin global:=1; EdLogin.color:=clInactiveCaptionText; end; //............................ if EdPassword.Text='' then begin global:=1; EdPassword.color:=clInactiveCaptionText; end; if global = 1 then begin Showmessage('Rellene los campos marcados para continuar'); global:=0; end else if global = 0 then begin {Verificar si ya existe el producto} Datos.QryEmpleado.Active:= False; Datos.QryEmpleado.SQL.Clear; Datos.QryEmpleado.SQL.Add('SELECT *'); Datos.QryEmpleado.SQL.Add('FROM Empleado'); Datos.QryEmpleado.SQL.Add('WHERE NumeroEmpleado =' + '''' + EdNumEmpleado.Text + ''''); Datos.QryEmpleado.Active:= True; If Datos.QryEmpleado.RecordCount > 0 then Application.MessageBox('La clave de empleado ya existe. Verifique los datos !!!', 'Error', MB_OK + MB_ICONERROR) Else LblEncriptado.Caption := encriptar(EdPassword.Text, 10); Datos.QryEmpleado.Active:= False; Datos.QryEmpleado.SQL.Clear; Datos.QryEmpleado.SQL.Add('INSERT INTO Empleado VALUES('); Datos.QryEmpleado.SQL.Add(Quotedstr(EdNumEmpleado.Text) + ','); Datos.QryEmpleado.SQL.Add(Quotedstr(LblClaveDireccion.Caption) + ','); Datos.QryEmpleado.SQL.Add(Quotedstr(EdLogin.Text) + ','); Datos.QryEmpleado.SQL.Add(Quotedstr(LblEncriptado.caption) + ','); Datos.QryEmpleado.SQL.Add(Quotedstr(EdNombre.Text) + ','); Datos.QryEmpleado.SQL.Add(Quotedstr(EdAppaterno.Text) + ','); Datos.QryEmpleado.SQL.Add(Quotedstr(EdApmaterno.Text) + ','); Datos.QryEmpleado.SQL.Add(EdNivel.Text + ')'); Datos.QryEmpleado.ExecSQL; Datos.QryEmpleado.Active:= True; //limpiar de componentes lblEncriptado.Caption:=''; EdNumEmpleado.Text:=''; LblClaveDireccion.Caption:=''; Edlogin.Text:=''; EdNombre.Text:=''; EdAppaterno.Text:=''; EdApmaterno.Text:=''; EdNivel.Text:=''; //BtnNuevo.Enabled:=true; end; end; |
#2
|
||||
|
||||
Hola,
Sobra la línea que dice Datos.QryEmpleado.Active:= True; Ya que con ExecSql ya se está ejecutando una vez el Insert.
__________________
"constructive mind, destructive thoughts" |
#3
|
|||
|
|||
resuelto
bueno de nueva cuenta gracias...problema solucionado......
gracias TOPX |
|
|
Temas Similares | ||||
Tema | Autor | Foro | Respuestas | Último mensaje |
cómo Insertar un registro | maximo_nashir | PHP | 1 | 14-07-2007 08:06:05 |
Insertar un registro | psll | Conexión con bases de datos | 2 | 26-10-2006 19:33:42 |
Problemas al insertar registro | dvlt | Firebird e Interbase | 4 | 10-10-2005 20:51:59 |
Insertar Nuevo Registro | perillan | Conexión con bases de datos | 3 | 24-04-2005 14:30:23 |
Error al insertar un registro en la BD | RiverPlate | Conexión con bases de datos | 3 | 08-12-2004 15:53:18 |
|