|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
c# and data navigatorI have an access database dataset which a draggedonto a form which also put
the data navigator on the form. The problem is that when I ADD a new record witht he add button, it gives me a primarykey that has already been used and deleted before in the database. Then of course when you try to save it you get an error because access won't allow this. I do not undertand why this primarykey issue is happening? If I create a new record in the access database itself, it operated correctly. Any ideas? Chris,
If it is an autoincrement ident, than the ID that is showed in your datarow is not used at insert time. Have a look at the seed properties from a column, Cor Show quote "Chris" <Ch***@discussions.microsoft.com> schreef in bericht news:615E00B9-6645-45B3-970A-B714B906E306@microsoft.com... >I have an access database dataset which a draggedonto a form which also put > the data navigator on the form. The problem is that when I ADD a new > record > witht he add button, it gives me a primarykey that has already been used > and > deleted before in the database. Then of course when you try to save it you > get an error because access won't allow this. > > I do not undertand why this primarykey issue is happening? If I create a > new record in the access database itself, it operated correctly. > > Any ideas? > If the primary key is an autonumber field, set the seed and increment to -1
on the table adapter. It is incrementing forward, replacing those already there. If set to -1, when it writes it to the database, it will assign the appropriate number to it. Robin S. ----------------------- Show quote "Chris" <Ch***@discussions.microsoft.com> wrote in message news:615E00B9-6645-45B3-970A-B714B906E306@microsoft.com... >I have an access database dataset which a draggedonto a form which also >put > the data navigator on the form. The problem is that when I ADD a new > record > witht he add button, it gives me a primarykey that has already been used > and > deleted before in the database. Then of course when you try to save it > you > get an error because access won't allow this. > > I do not undertand why this primarykey issue is happening? If I create a > new record in the access database itself, it operated correctly. > > Any ideas? > Thanks. How to set seed? is this a property of the table adapter?
Yes, it is an autonumber field in Access table. Show quote "RobinS" wrote: > If the primary key is an autonumber field, set the seed and increment to -1 > on the table adapter. It is incrementing forward, replacing those already > there. If set to -1, when it writes it to the database, it will assign the > appropriate number to it. > > Robin S. > ----------------------- > "Chris" <Ch***@discussions.microsoft.com> wrote in message > news:615E00B9-6645-45B3-970A-B714B906E306@microsoft.com... > >I have an access database dataset which a draggedonto a form which also > >put > > the data navigator on the form. The problem is that when I ADD a new > > record > > witht he add button, it gives me a primarykey that has already been used > > and > > deleted before in the database. Then of course when you try to save it > > you > > get an error because access won't allow this. > > > > I do not undertand why this primarykey issue is happening? If I create a > > new record in the access database itself, it operated correctly. > > > > Any ideas? > > > > > In the data set designer, if you click on the autonumber column and look at
the properties, they are called autoincrementseed and autoincrementstep. I think you need to set AutoIncrement to True, too. Robin S. ---------------------------------------------------------- Show quote "Chris" <Ch***@discussions.microsoft.com> wrote in message news:3A07EBA0-5644-4FC9-927D-605E22CB6F35@microsoft.com... > Thanks. How to set seed? is this a property of the table adapter? > Yes, it is an autonumber field in Access table. > > "RobinS" wrote: > >> If the primary key is an autonumber field, set the seed and increment >> to -1 >> on the table adapter. It is incrementing forward, replacing those >> already >> there. If set to -1, when it writes it to the database, it will assign >> the >> appropriate number to it. >> >> Robin S. >> ----------------------- >> "Chris" <Ch***@discussions.microsoft.com> wrote in message >> news:615E00B9-6645-45B3-970A-B714B906E306@microsoft.com... >> >I have an access database dataset which a draggedonto a form which also >> >put >> > the data navigator on the form. The problem is that when I ADD a new >> > record >> > witht he add button, it gives me a primarykey that has already been >> > used >> > and >> > deleted before in the database. Then of course when you try to save it >> > you >> > get an error because access won't allow this. >> > >> > I do not undertand why this primarykey issue is happening? If I >> > create a >> > new record in the access database itself, it operated correctly. >> > >> > Any ideas? >> > >> >> >> |
|||||||||||||||||||||||