Why is this throwing a primary key violation!!?!?
- From: Josh Fraser <jfraser@xxxxxxxxx>
- Date: Mon, 26 Sep 2005 09:00:15 -0400
Morning all...
I'm scratching my head to find out why this is throwing a primary key violation.
aTables is an Array of type Tadoquery.
What happens is qryJobInfo is the "Header" of a log, and the qryJobTasks is the detail lines. I save the header, grab the job number and then pass it to the query to save the detail lines.
It works great when I create a brand new job and add 3 or 4 detail lines, but whenever I create a job, save it and go back to modify it it throws a PK violation.
Josh
procedure TdmLogInfo.SaveJob; var i: smallint; begin dmCustomer.SaveCustomer;
dmShippingAssumptions.SaveAss(qryJobInfo.FieldByName('CustomerID').AsInteger);
dmGlobal.conGlobal.BeginTrans;
try
// Grabs the Customer ID and makes sure the Job Customer ID = the Open Customer
qryJobInfo.FieldByName('CustomerID').Value := dmCustomer.qryGetCustomer.FieldByName('CustomerID').value;
if qryJobInfo.State in [dsEdit, dsInsert] then qryJobInfo.Post;
qryJobInfo.UpdateBatch(arAll);for i := 1 to high(aTables) do begin // Violation gets thrown //around here
with aTables[i] do begin
first;
while not EOF do begin
Edit;
FieldByName('JobNo').AsInteger := JobNo;
Post;
Next;
end;
UpdateBatch(arAll);
end;
end;
dmGlobal.conGlobal.CommitTrans;
except
dmGlobal.conGlobal.RollbackTrans;
end;
end;
.
- Follow-Ups:
- Re: Why is this throwing a primary key violation!!?!?
- From: Guillem
- Re: Why is this throwing a primary key violation!!?!?
- Prev by Date: Re: ADO failing on XP - untangling MDAC and Jet DLLs
- Next by Date: How format float in TDBText using ADO??
- Previous by thread: Passing parameters by Name rather than position
- Next by thread: Re: Why is this throwing a primary key violation!!?!?
- Index(es):