Subject Re: [firebird-support] Get the value of generated primary key after an insert
Author Radu Sky
Adriano wrote:
> Hi Radu & Aage,
>
>
>> Shouldn't be MsgBox MyVar ?
>> Just a shot in the dark...
>
> Dim MyVar as Integer
> query =3D "SELECT GEN_ID(GEN_PRATICHE_IDPRATICA, 1) as MYVAR FROM RDB$DATAB=
> ASE;"
> cn.Execute query
> MsgBox Myvar
> Returns Always 0
>
> It's darker than before ..
> Some more light ?
>

Hello,
I was referring to MyVar field.
MsgBox Myvar will always return 0 since you declared as local variable;
You need to retrieve the field value 'MyVar' from your query cn like
from any ordinary table.

MsgBox cn.fieldbyname('MyVar').value

I must admit that I don't know the syntax there but you should do
something like that

HTH
Radu