Home All Groups Group Topic Archive Search About
Author
2 Mar 2007 2:17 AM
Chris
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?

Author
2 Mar 2007 4:30 AM
Cor Ligthert [MVP]
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?
>
Author
2 Mar 2007 4:37 PM
RobinS
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?
>
Author
3 Mar 2007 3:17 AM
Chris
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?
> >
>
>
>
Author
4 Mar 2007 1:04 AM
RobinS
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?
>> >
>>
>>
>>

AddThis Social Bookmark Button