Update Failed. Found 0 records

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jigesh
Posts: 16
Joined: Tue 11 Oct 2005 21:04

Update Failed. Found 0 records

Post by jigesh » Fri 14 Apr 2006 19:32

Jigesh wrote: I am using Delphi7, SDAC 3.70.1.25 and MSSQL 7.

Consider the following code.

procedure TVCTData.tblPONewRecord(DataSet: TDataSet);
begin
with tblNewPONo do
begin
Open;
try
Edit;
tblPOPO_ID.Value := tblNewPONoNextPOID.Value;
tblNewPONoNextPOID.Value := tblNewPONoNextPOID.Value + 1;
Post;
finally
Close;
end;
end;
tblPOPO_Date.Value := Date;
tblPODateReq.Value := Date + 7;
tblPOPOStatus.Value := 'Open';
tblPOShipTo.Value := 1001;
tblPOTaxRate.AsFloat := 6.75;
tblPOPOSubTotals.AsCurrency := 0;
tblPOPOTotal.AsCurrency := 0;
tblPOTaxChgs.AsCurrency := 0;
end;

When I click on a button to add a new record this code is executed with no problems. It also issues me a new PO Number. But if I open another instance of the program from another computer and click on the button to add a new record it gives me an error message "Update Failed. Found 0 records." But if I exit out of the program from the second computer and then open the program again from the second computer the code executes successfully and issues me the next PO number in sequence. How can I resolve this issues. I have tried all the solutions in the forum for this type of problem, but no success. I need to resolve this as soon as possible because I am stuck on this problem for now 2 weeks.

Any help will be really appreciated.

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Mon 17 Apr 2006 08:44

It is possible that you change key field value on server from first computer, and the value on second computer gets old. When you try to update record, SDAC generates query with key field value in WHERE clause to update required record. But record with such value of keyfield does not exist, and update fails.
Try to refresh data before edit, or if you have TIMESTAMP fields see TCustomMSDataSet.Options.CheckRowVersion property in SDAC help.

Post Reply