[fpc-devel] odbcconn.pas

Michael Van Canneyt michael at freepascal.org
Fri Mar 14 10:08:19 CET 2014



On Thu, 13 Mar 2014, Nathan Wild wrote:

> Thanks so much for responding!  I am extremely excited about the prospect of getting this working.
> Nothing I do in databound controls seems to commit anything to the underlying dataset.
> 
> If I open a connection, activate a TSQLQuery with 'SELECT * FROM AnyTable', connect it toa dbgrid, etc.  I can delete rows,
> edit data etc. and it appears to work normally.  Changes take effect inside the controls, values change in the dataset,
> etc. but as soon as I disconnect and reconnect the dataset all my changes are reverted.
> 
>   ODBCConnection1.Connected := TRUE;
>   SQLQuery1.SQL.Clear();
>   SQLQuery1.SQL.Append('SELECT * FROM AnyTable');
>   SQLQuery1.Active := TRUE;
>   SQLQuery1.Delete();
>   SQLQuery1.Edit();
>   SQLQuery1['AnyField'] := 'CHANGED';
>   SQLQuery1.Post();
> 
> All of these changes take place in the UI.  i.e. the first row is deleted and the field is modified in the second.  As soon
> as I close and re-open the table, both changes are undone.

You must call applyupdates. 
Post only modifies the in-memory copy of the data, but doesn't actually execute any queries on the database.
Only when you call ApplyUpdates(), the SQL will be executed to update the database.

Michael.


More information about the fpc-devel mailing list