Jump to content
bazzer747

GetLastAutoGenValue

Recommended Posts

Hi

I've just seen the above function which Firedac provides, and read the DocWiki about it and it would be very helpful in my project as I create new records. However, I'm having difficulty understanding quite how it works, or rather what it requires passed with it.

 

The Docwiki provides an example of how to program with it:

ShowMessage(VarToStr(ADConnection1.GetLastAutoGenValue('MyGen')));

My question is - what is 'MyGen' referring to? I'm using MS SQL and the info says the method returns the last autogenerated value in the session. In my table I have an autogenerated column called 'ID' (an integer). I've changed the above example to read: ShowMessage( VarToStr( dm.fdcMSLTest.GetLastAutoGenValue( 'ID' ))); assuming what it wants passed to it is the fieldname that is autogenerated. However, this gives an error when run 'Capability is not supported'.

 

Any thoughts would be appreciated.

Share this post


Link to post

I am using it with an empty string with MARIADB/MySQL.

Quote

ConnectionProd.GetLastAutoGenValue('');

According to the documentation this should work for MSSQL too.

  • Like 1

Share this post


Link to post

Works a treat, many thanks.

 

Why can't the documentation be a little more helpful, especially as the guys who are looking this up won't know how to use it. Frustrated, but glad for this forum 🙂

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×