Does InsertID works for MyTable?
Does InsertID works for MyTable?
Hi;
im trying to obtain the last id after an Mytable.Append...Mytable.Post;
but MyTable.InsertId returns 0 every time.
Any Advice?
im trying to obtain the last id after an Mytable.Append...Mytable.Post;
but MyTable.InsertId returns 0 every time.
Any Advice?
-
Poerenstamper
- Posts: 4
- Joined: Thu 04 Oct 2007 10:36
I'm afraid I'm having some trouble with 'InsertID' too. Some data:
- MyDAC 5 Pro
- MySQL 5.0.38
- Delphi 7
I use the TMyCommand to insert a records, in the following way:
The scheme of this table 'mailings' is (ID is an AUTO_INCREMENT field):
In the event handler MyCommand1AfterExecute I have:
Now the problem: the first I insert a record, MailingID remains the default value (0), however the second time it works just fine.
I tried several things, like refreshes and so on, but the result stays the same.
Thanks in advance for your answers!
Wessel
- MyDAC 5 Pro
- MySQL 5.0.38
- Delphi 7
I use the TMyCommand to insert a records, in the following way:
Code: Select all
with MyCommand1 do
begin
SQL.Clear;
SQL.Add('INSERT INTO mailings (date) VALUES (NOW())');
Prepare;
Execute;
end;
Code: Select all
Mailings(ID, date, sent);Code: Select all
if Result then
MailingID := MyCommand1.InsertId;
I tried several things, like refreshes and so on, but the result stays the same.
Thanks in advance for your answers!
Wessel
Last edited by Poerenstamper on Thu 04 Oct 2007 12:49, edited 1 time in total.
-
Poerenstamper
- Posts: 4
- Joined: Thu 04 Oct 2007 10:36