cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

How to keep Datatable's Primary key Column Auto increment .

VaibhavShinde
16-Pearl

How to keep Datatable's Primary key Column Auto increment .

Hi ,

I wanted to have column in Datatable as primary key which will  increment by 1 automatically whenever add the row. how to make it auto increment.

 

Thanks

2 REPLIES 2

Datatables do not have that function, so you would have to create a wrapper service around your insert that adds that number.

Not sure what you need this for, but datatables aren't really designed with this in mind. If you really need this, then every insert, I would record the number used and write that to a property (just add to database) so that you won't need to run a service against the table to figure out what number to use next, that can potentially cause issues if you do a lot of operations in quick succession against the datatable.

It can't be done using datatables, you can go ahead with pai chung's work around as mentioned above but it will goes for toss when there are huge amount of insertions.

 

Better you create you own table in database and made your column as auto increment. In thingworx, create a Thing with database as base template and then write your service based on your requirement. Hope this helps for your requirement.

Top Tags