Page 1 of 1

Persistent Autoinc fields

Posted: Wed 03 Jul 2013 11:44
by softsmith
MySQL version 7.2.8 for XE2

When I create persistent fields from either a MySQL or MyTable, Autoinc fields are shown as TWordfield instead of TAutoincfield.
How can I change this so autoinc fields are created ? (Of course the database tables have been set correctly to autoinc)

Thanks for your help

Re: Persistent Autoinc fields

Posted: Thu 04 Jul 2013 13:35
by DemetrionQ
Hello.

MyDAC fills in auto-incremental fields automatically on inserting a new record to a dataset, independently on whether they have the TWordField type or TAutoIncField.

Re: Persistent Autoinc fields

Posted: Sun 07 Jul 2013 02:02
by softsmith
Thanks for your reply.

Unfortunately, I work a lot with memory tables and string grids, and it is important that I know what the data type is when I copy data from the MyQuery to the memory table or string grid.
I could check each time with a "SHOW FULL COLUMNS FROM xxxtable", and then see what the "extra" column is, but this means a round trip to the database every time.

Any suggestions ?

Thanks

Re: Persistent Autoinc fields

Posted: Sun 07 Jul 2013 02:25
by softsmith
I have just been reading the help file, and one thing I found interesting was the section on data type mapping. Can this be extended to cover autoincs ?

Thanks

Re: Persistent Autoinc fields

Posted: Mon 08 Jul 2013 12:51
by DemetrionQ
Hello.

Data Type Mapping is not designed for definition of auto-incremental fields or mapping in TAutoIncField.
You can define whether a field is auto-incremental in the following way:

Code: Select all

  if MyQuery1.GetFieldDesc('YourField').IsAutoIncrement then
    // ...  Field is AutoIncrement

Re: Persistent Autoinc fields

Posted: Tue 09 Jul 2013 00:18
by softsmith
Thanks for that. Just what I was looking for.

Regards

Re: Persistent Autoinc fields

Posted: Tue 09 Jul 2013 08:05
by DemetrionQ
If any other questions come up, please contact us.

Re: Persistent Autoinc fields

Posted: Mon 25 Jul 2016 21:26
by m227
Hi,
Is there any way to make Field TAutoInc type when obtaining field definitions from MySQL Table? One of components I use require it, if the key value of new record would be set automatically.
Michal

Re: Persistent Autoinc fields

Posted: Tue 26 Jul 2016 09:54
by ViktorV
The similar question has already been discussed on our forum. Follow the link viewtopic.php?f=7&t=7332