Persistent Autoinc fields

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
softsmith
Posts: 19
Joined: Fri 27 Jan 2012 01:17

Persistent Autoinc fields

Post by softsmith » Wed 03 Jul 2013 11:44

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

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Persistent Autoinc fields

Post by DemetrionQ » Thu 04 Jul 2013 13:35

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.

softsmith
Posts: 19
Joined: Fri 27 Jan 2012 01:17

Re: Persistent Autoinc fields

Post by softsmith » Sun 07 Jul 2013 02:02

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

softsmith
Posts: 19
Joined: Fri 27 Jan 2012 01:17

Re: Persistent Autoinc fields

Post by softsmith » Sun 07 Jul 2013 02:25

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

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Persistent Autoinc fields

Post by DemetrionQ » Mon 08 Jul 2013 12:51

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

softsmith
Posts: 19
Joined: Fri 27 Jan 2012 01:17

Re: Persistent Autoinc fields

Post by softsmith » Tue 09 Jul 2013 00:18

Thanks for that. Just what I was looking for.

Regards

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Persistent Autoinc fields

Post by DemetrionQ » Tue 09 Jul 2013 08:05

If any other questions come up, please contact us.

m227
Posts: 75
Joined: Mon 06 Aug 2007 12:41

Re: Persistent Autoinc fields

Post by m227 » Mon 25 Jul 2016 21:26

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

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Persistent Autoinc fields

Post by ViktorV » Tue 26 Jul 2016 09:54

The similar question has already been discussed on our forum. Follow the link viewtopic.php?f=7&t=7332

Post Reply