Addnew creating two records?

A

Andrew Oliner

Hi,

I have a SQL Server 2000 database with an Identity Column called IssueNum
which auto-increments each time a new record is created.

I'm using the ADO.net 2.0 tools, a BindingSource and a BindingNavigator.
When I click on the AddNew button on the Binding Navigator, it adds two
records to the datatable, not just one. The AddNew button doesn't do
anything other than call the AddNew function of the Binding Source.

The new records don't get written back to SQL Server, but it's very annoying
to have one record, click the AddNew button, and then have three records.

I've seen a previous Newsgroup post where someone said that this was a known
issue with adding new records to a table with an Autoincrement field, but
there was no workaround mentioned.

Please help,

Andy
 
J

Jim Hughes

If you want to handle the AddNew functionality yourself, remove the value
that is automatically entered for the AddNewItem property of the
BindingNavigator instance.

By default, it points to the BindingNavigatorAddNewItem button and
automatically invokes the AddNew functionality without needing to write your
own code behind the button.

The Delete button will remove an item from the bound IList but not delete it
to the database.

The Save button does nothing without code behind.
 
A

Andrew Oliner

I am using the BindingSource, which I have no experience with. The
BindingNavigator just invokes the AddNew method of the BindingSource, which
is what generates the two new records instead of one.

It's not that I WANT to handle the AddNew myself, it's just that I want it
to be done correctly. Actually, I have a problem because I don't understand
the BindingSource well enough to handle some processes in the old-style
Datarow/Datatable and other things using the BindingSource. For me, if I
can't get the BindingSource to do things right, I'll have to abandon it and
go back to the old ADO.net 1.0 style.

Btw, I poked around further on the web, and found that some people have been
able to fix this problem by changing the Identity field's autoincrement
settings in the Dataset Designer. This didn't solve the problem for me.
 

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