Page 1 of 1

DataTables and autoincrement on primary keys

Posted: Wed 29 Mar 2006 19:40
I'm getting very strange problems with the MySQLDataTable (3.5 beta) working with simple primary keys.

I have a simple table with a primary key called 'ID' which is non-null autoincrementing integer. I create a row manually using the db editor. Now I write a simple program that does a "SELECT * FROM mytable".

I add a row in code, and go to update. It comes back with an error because the MySQLDataTable component is not incrementing the primary key 'ID' to 2, and in instead trying to use 1.

Another scenario:

I have a table with 100 records, again a primary key of 'ID'. I run a query "SELECT * FROM mytable WHERE field1 = 'xxx'" which returns records #'d 30-40.

I try to add a row to the resulting datatable. It fails because it is trying to use a primary key value of '41'.

Anybody else run into this problem. The MySQLDataTable is a dream for fast coding when it works, but these problems are unacceptable for using it.

Posted: Thu 30 Mar 2006 09:06
by Alexey
Could you please provide us with your code sample that generates the error.

Posted: Thu 30 Mar 2006 14:12
Please disregard the second scenario. Oleg has code samples from the first scenario and I believe was able to recreate the problem on his end.