Buenas Noches a tod@s
Mi problema es el siguiente:
Estoy trabajando con delphi 7, access 2003 y Ado. La conexion esta en un Data Module y lo hago a traves de
Microsoft.Jet.OLEDB.4.0.
Tengo un formulario que funciona como facturacion en el cual lo manejo con 2
TClientDataset; el problema es que al momento del
ApplyUpdate(0) del primer ClientDataSet (el que hace referencia al encabezado de la factura) me da el error de
"Project Sistema.exe raised exception class EDBClient with message 'Key violation.'. Process stopped. Use Step or Run to continue"
Antes de grabar le asigno los valores a este uno por uno. El codigo que empleo es este:
Código Delphi
[-]
CDS1.Append;
CDS1Tipo_Doc.Value := 'F';
CDS1Ano.Value := inttostr(Ano);
CDS1Numero.Value := numerof;
CDS1Fecha_Emision.Value := strtodate(edit39.Text);
if DBLCB1.KeyValue <> null then
begin
CDS1Cod_Cliente.Value := dblcb1.KeyValue;
end
else
begin
CDS1Cod_Cliente.Value := 0;
end;
CDS1Forma_Pago.Value := DBRG1.Value;
CDS1Tipo_Cliente.Value := '';
if edsub.Text <> '' then
CDS1SubTotal.Value := strtofloat(edsub.Text)
else
CDS1SubTotal.Value := 0;
if eddesc.Text <> '' then
CDS1Descuento.Value := strtofloat(eddesc.Text)
else
CDS1Descuento.Value := 0;
If edimp.Text <> '' then
begin
CDS1Impuesto.Value := strtofloat(edimp.Text);
end
else
CDS1Impuesto.Value := 0;
If edtotal.Text <> '' then
CDS1Total.Value := strtofloat(edtotal.Text)
else
CDS1Total.Value := 0;
CDS1Fechacre.Value := dateOf(Now);
CDS1Horacre.Value := Now;
CDS1Userwcre.Value := String(Nombre);
CDS1Estacioncre.Value := String(buffer);
CDS1Estado.Value := 'A';
CDS1.ApplyUpdates(0);
La clave principal de mi tabla esta compuesta por el
Tipo_Doc, Ano, Numero
Alguien sabe donde estoy fallando para que me de ese error?
Gracias anticipadas
Saludos