View Full Version : DBGrid and autoindexed fields
08-15-2001, 06:43 AM
in my table, the primary key is autoindexed.
i put an editable dbgrid according to that table.
now when i add a new record, the value it gives to it is "0"
only when i close my app and re-enter it, i see the values like it should be. how come ?
08-15-2001, 09:51 AM
Are you sure you need to use an autoindex field? I have found them to cause all kinds of trouble. I usually use an integer and a routine to find the last value and add one to it so it is unique. The field always ends up showing the proper value.
08-15-2001, 10:09 AM
yeah but for that i will need always to check the last value in the table add 1 and use the new value.
so each time i will need to do a query just for adding a new value ?
and i want to make it as user-friendly as i can, so i made the dbgrid editable so the information can b edited by the user with no clicks and stuff.
08-15-2001, 12:08 PM
Do you mean AutoIncr(ement)?
One way to handle this is to do this:
Of course, this would move the cursor in the table but you
want to see the new value, right?
vBulletin® v3.8.7, Copyright ©2000-2013, vBulletin Solutions, Inc.