After using TMyCommand with the insert command, insertid is only different to 0 if the program is compiled with debug info.
Got the newest (520) mydac build, and could reproduce it.
Some idea what i could do wrong?
It seems i must compiledf with assertion on!!!
Why that? Is there any workaround?
I found the place where the assertion take places:
procedure TMyCommand.Execute(Iters: integer);
var
v: variant;
begin
BeginConnection;
try
inherited;
Assert(Connection.IConnection.GetProp(prLastInsertId, v));
{$IFDEF VER6P}
FInsertId := v;
{$ELSE}
FInsertId := PInt64(@TVarData(v).VInteger)^;
{$ENDIF}
finally
EndConnection;
end;
end;
Is there anyway to get the info that is stored in v outside myaccess.pas?
Since i normally work with asssertion off.
Thx in advance.
insertid works with debug mode one, without it returns always 0
-
iskywalker
- Posts: 16
- Joined: Mon 25 Jun 2007 15:00
There is a known bug with the InsertId value in the AfterExecure event. It will be fixed in the next build of MyDAC.
With the current MyDAC build the following code should work correctly:
With the current MyDAC build the following code should work correctly:
Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
begin
MyCommand1.Execute;
ShowMessage(IntToStr(MyCommand1.InsertId));
end;-
iskywalker
- Posts: 16
- Joined: Mon 25 Jun 2007 15:00
Well it works already, but only if i set the assertion flag in delphi project options (compiler), normally this isnt needed!
The assert function will only be used (activated) if the assert flag is set.
So the code below will be only executed if this flag is set:
Assert(Connection.IConnection.GetProp(prLastInsertId, v));
I wonder why! since it should work without the assert flag, or?
Thx for the Answer!
The assert function will only be used (activated) if the assert flag is set.
So the code below will be only executed if this flag is set:
Assert(Connection.IConnection.GetProp(prLastInsertId, v));
I wonder why! since it should work without the assert flag, or?
Thx for the Answer!
Disabling this flag is not a solution.
Could you send us a complete small sample at mydac*crlab*com to demonstrate the problem, including script to create and fill tables used in the sample? It is necessary for us to make sure that the problem has been fixed completely.
Also supply the following information:
- exact version of MyDAC. You can see it in the About sheet of TMyConnection Editor;
- exact version of your IDE;
- exact version of MySQL server and MySQL client. You can see it in the Info sheet of TMyConnection Editor.
Could you send us a complete small sample at mydac*crlab*com to demonstrate the problem, including script to create and fill tables used in the sample? It is necessary for us to make sure that the problem has been fixed completely.
Also supply the following information:
- exact version of MyDAC. You can see it in the About sheet of TMyConnection Editor;
- exact version of your IDE;
- exact version of MySQL server and MySQL client. You can see it in the Info sheet of TMyConnection Editor.
-
iskywalker
- Posts: 16
- Joined: Mon 25 Jun 2007 15:00
Hi!
http://delphi.about.com/library/rtl/blrtlAssert.htm
There is written:
Since assertions are not usually used in final product version, Delphi compiler includes directives to disable the generation of assertion code:
$ASSERTIONS ON/OFF (long form)
But you use in the source code:
Assert(Connection.IConnection.GetProp(prLastInsertId, v));
So if the assert would be deleted and only
if not Connection.IConnection.GetProp(prLastInsertId, v) then
DatabaseError('Couldn't get Property);
Thx
http://delphi.about.com/library/rtl/blrtlAssert.htm
There is written:
Since assertions are not usually used in final product version, Delphi compiler includes directives to disable the generation of assertion code:
$ASSERTIONS ON/OFF (long form)
But you use in the source code:
Assert(Connection.IConnection.GetProp(prLastInsertId, v));
So if the assert would be deleted and only
if not Connection.IConnection.GetProp(prLastInsertId, v) then
DatabaseError('Couldn't get Property);
Thx