[Lazarus] Need some help with UpdateSQL in TSQLQuery and TMySQL50Connection
Howard Lee Harkness
howard.lee.harkness at gmail.com
Sat Jun 14 23:06:13 CEST 2008
I was able to get the Insert and Refresh buttons to work with code like
this:
case Button of
nbPost: SQLQuery1.Applyupdates;
nbRefresh: begin SQLQuery1.Close; SQLQuery1.Open; end;
...
end;
However, it doesn't seem to matter what I put in for nbDelete. I always get
the error "There are no fields found to generate the where-clause" if I do
ApplyUpdates for nbDelete. If I put nothing in there, the field appears to
be deleted, but it is still in the table, and comes back to the grid when I
press "refresh".
On Sat, Jun 14, 2008 at 3:22 PM, Howard Lee Harkness <
howard.lee.harkness at gmail.com> wrote:
> Ok, I tried calling ApplyUpdates, and I did not detect any difference.
> Could you perhaps show me in the code below exactly WHERE I need to call
> ApplyUpdates?
>
> On Tue, May 27, 2008 at 5:00 AM, Joost van der Sluis <joost at cnoc.nl>
> wrote:
>
>> That's true. You have to call 'TSQLQuery.ApplyUpdates' Then all changes
>> in the local, in-memory changes-buffer are converted into
>> update/insert/delete statements and executed on the underlying database.
>>
>> For those connections that do support transactions, you also have to do
>> TSQLTransaction.Commit(Retaining).
>>
>
>
> unit Zipcode;
>
> {$mode objfpc}{$H+}
>
> interface
>
> uses
> Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
> mysql50conn, sqldb, db, DBGrids, DbCtrls;
>
> type
> { TForm1 }
> TForm1 = class(TForm)
> Datasource1: TDatasource;
> DBGrid1: TDBGrid;
> DBNavigator1: TDBNavigator;
> MySQL50Connection1: TMySQL50Connection;
> SQLQuery1: TSQLQuery;
> SQLTransaction1: TSQLTransaction;
> private
> { private declarations }
> public
> { public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> initialization
> {$I zipcode.lrs}
> end.
>
>
> --
> Howard Lee Harkness
>
>
--
Howard Lee Harkness
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20080614/0cf6d5aa/attachment-0007.html>
More information about the Lazarus
mailing list