c# and data navigator

G

Guest

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?
 
C

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
 
R

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.
 
G

Guest

Thanks. How to set seed? is this a property of the table adapter?
Yes, it is an autonumber field in Access table.
 
R

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.
----------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top