|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Addnew creating two records?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 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. Show quote "Andrew Oliner" <andyo@me.oliner.nospamhere.com> wrote in message news:OnZfmRLaGHA.3896@TK2MSFTNGP05.phx.gbl... > 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 > 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. Show quote "Jim Hughes" <NOSPAMJ3033@Hotmail.com> wrote in message news:e$gHKwMaGHA.3652@TK2MSFTNGP03.phx.gbl... > 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. > > "Andrew Oliner" <andyo@me.oliner.nospamhere.com> wrote in message > news:OnZfmRLaGHA.3896@TK2MSFTNGP05.phx.gbl... >> 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 >> > > |
|||||||||||||||||||||||