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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with updating Paradox tables!

Status
Not open for further replies.

selena1

Programmer
Apr 7, 2003
69
I have a Paradox teble with next fields:

ID_member.................AUTOINC (Primary Key)
LastName...................CHAR(50)
FirstName...................CHAR(50)

On the form I use: DataSource, Query, DBGrid and DBNavigator. I have set SQL property of the Query component like:
"SELECT * FROM Members"
Everything work fine until I sort records. I change SQL property so that have value:
"SELECT * FROM Members ORDER BY LastName"
Now I get DataSet that I can't edit, insert or delete (read only). So I tried to use component UpdateSQL. I have set properties of Query components on next values: CachedUpdates = True, RequestLive = True, SessionName = Default and UpdateObject = UpdateSQL1.
Also, I have set property Modify of UpdateSQL1 component:
"UPDATE Members SET LastName = :LastName, FirstName = : FirstName"
I have wrote OnUpdateRecord event of Query component:
"if( UpdateKind = ukModify ) then
begin
UpdateSQL1.Apply(UpdateKind);
UpdateAction := uaApplied;
end;"
Also I have OnCreate event of Form component:
"Query1.Open;
Query1.Database.TransIsolation := tiDirtyRead;"
I col updates with click event of button:
"Query1.Database.ApplyUpdates( [Query1] );"
All the time I get a mistake: "UPDATE FAILED".
CAN ANYBODY HELP ME, PLEASE?
 
Whoa! Too much!

First, try using TQuery.CachedUpdates without an UpdateSQL and without RequestLive: it usually works fine.

Second, if you are going to use UpdateSQL, the Modify statement has to specify with row it is going to update, e.g.
Code:
UPDATE Members SET LastName = :LastName, FirstName = :FirstName WHERE ID_Member = :ID_Member
("There is always a WHERE clause").

If these don't work, let me know.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top