ASPX Grid View: Serial number for deleted MySQL rows are empty.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajsrmc
    New Member
    • Jan 2010
    • 9

    ASPX Grid View: Serial number for deleted MySQL rows are empty.

    Hello Guys!
    I have a mysql table which is connected with aspx page in grid view, in the connected table i have assigned Serial number column as Primary key and as well in auto increment, by using the delete option in grid view i have deleted some rows but the serial numbers which i deleted are still like empty and its not assigned for next data. Is it because of the primary key? need help!
    thanks in advance
    Last edited by Atli; Feb 3 '10, 04:48 PM. Reason: Made the title a bit more descriptive.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    If the serial number column - which I presume is a simple integer field - is marked AUTO_INCREMENT, then MySQL automatically assigns it the next number that has not been used. If you have previously deleted a row, the serial number it used will not be reused.

    This - I assume - is partly done to simplify, and thus increase the performance, of the AUTO_INCREMENT number generation, and to maintain the integrity of the data. Meaning: in a MyISAM table, a deleted row could still potentially be referenced by other tables (FK relationships are not enforced), so re-using the ID of that row might create unwanted references between tables.

    If you want your code to re-use previously used, and deleted, serial numbers, you will have to write a routine to do that manually. - Granted, I know little of .Net, so there may well be some built in feature that handles this, but I wouldn't know. (Try asking in the .Net forum.)

    Comment

    Working...