Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interbase & Delphi

Status
Not open for further replies.

DaZZleD

Programmer
Oct 21, 2003
886
US
i'm using a Interbase database form delphi and get the following error when trying to delete, update records:
'Update Failed'.

the code I use is:

form1.DataSource2.DataSet.Close;
if form1.IBTransaction1.InTransaction then
form1.IBTransaction1.Commit;
form1.IBTransaction1.StartTransaction;
form1.IBUpdateSQL1.ExecSQL(ukDelete);
form1.IBTransaction1.Commit;
form1.IBQuery1.Open;
form1.DataSource2.DataSet.Open;
form1.DBGrid1.Refresh;

any help is appreciated
 
can you include the SQL that is being executed?

have you tried adding some exception handling to get a better idea as to what is causing the error? e.g.

form1.DataSource2.DataSet.Close;
try
if form1.IBTransaction1.InTransaction then
form1.IBTransaction1.Commit;

form1.IBTransaction1.StartTransaction;
try
form1.IBUpdateSQL1.ExecSQL(ukDelete);
form1.IBTransaction1.Commit;
except
on E: Exception do
begin
showmessage(Format('%s: %s', [E.ClassName, E.Message]));
form1.IBTransaction1.Rollback;
end;
end;

form1.IBQuery1.Open;
form1.DataSource2.DataSet.Open;
form1.DBGrid1.Refresh;
except
on E: Exception do showmessage(Format('%s: %s', [E.ClassName, E.Message]));
end;
 
the SQL was tested directly from SQLExplorer included in Delphi package and had no errors. It's pretty long, but basically it's like this:
'delete from tab06 where cnp="123456" and venitnet="123456"' (has about 4 more conditions)

The Exception class is EIBClientError. The message is Update Failed, error help context is 0.
The exception is thrown from the form1.IBUpdateSQL1.ExecSQL(ukDelete); statement.

any ideas?
 
I assume you are settings hte parameters at some stage? or is this being done automatically via teh Update link? If so, are you sure you aren't closing the dataset that provides these parameters????

Again, the more detail you can post about your application the better....sounds like you have tested the sql as much as you can aleady, but I have no idea as to which components are linked to which...

DataSource2 links to which component? IBQuery1? in which case, why do you open it twice?
 
I finally managed to tear the code to bits and see what's going on. The problem is that sql manages comparing cells to empty strings (like 'where no=""') but when using it with delphi, that raises an exception. I'm still confused about which component raises it, because of the strange Exception message. But once I modified the routine to add to the 'where' clause only the not null fields, all went ok. Thanks for everything BillDoorNZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top