index > .NET Framework Data Access and Storage > Inserting a row duplicates this row

Inserting a row duplicates this row

Hi,

I'll insert a row in a dataset, then to merging this with database,
after this, i sync my sqlservermobile database with the server,
all is ok, but if I'll fill the dataset (after syncing) this row
is duplicated with different guid (which is the key)

code:

datatable.Rows.Add(row)
DataSet changes = datatable.GetChanges()
datatable.Merge(changes)
datatable.AcceptChanges()

Syncing...

tableadapter.fill(datatable)
--> after this, the inserted row is duplicated but with a different
key (guid)

Any ideas?

THANK YOU!

grepe

Why are you mergning the changes back into the same dataset? This is creating your dup in the dataset and the db is assigning the new PK....Get your changes and then update the db

datatable.Update(Changes)

and if no error then call accept changes...

HTH




MSDN Technical Forums Moderator - Happy Coding :)
DMan1

I solved the problem.

The insert statement didn't have the guid - column within. So the
database was updated with a new guid. On this update dataset
got the new row from database with new guid. Old row with own
generated guid still exists in dataset.

>> Why are you mergning the changes back into the same dataset? This is creating your dup in the dataset and the db is assigning the new PK....Get your changes and then update the db

--> if database calculates some values, i won't get the changes back if i don't merge
the inserted changes.

grepe

grepe
reply 3

You can use google to search for other answers

 

More Articles

• Null Value exception thrown, need to change default action
• IsNotAllowDBNullViolated method throws NullReferenceException dur...
• Data Access Layer design
• OleDbCommand.Update method bug - parameter values overlap
• can't insert data into database
• Ado.Net 2.0 Provider compliance?
• add parameters to oledb
• Nobody can answer this question!
• Save data as xml file
• Crystal Report Linked to access database
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Concurrency Violation on 2 of 3 linked s
• oracleCommand error
• Problem using SqlDataAdapter/Query builder
• Control.DoDragDrop and Exceptions
• Load image column from database into ima
• Desiging Data Access
• TableAdapter insert/update/delete order
• Client-side redirect problem
• mapping issue in ado.net when executeNon
• Relationships in Typed Datasets
• Changing the database asociated with a D
• SQL Server Procedure call timeout from .
• TableAdapter Update problem
• Trusted_Connection Problem with VS2005
• Any way to display images in gridview?

Hot Articles

• Save and retrieve RTF Text from MSSQL DB
• Navigating Large Database
• database search engine class library
• Error opening a sample .mdf database
• Iframe & SqlDataSource
• Number of Query values and destination f
• Retrieving CLOB data from Informix
• table adapters - update
• Problem with SqlBulkCopy when destinatio
• Datatable value not displaying!!!
• Enterprise Library for .NET Framework 2.
• Transactionscope
• OracleClient don't connect, OleDB with s
• TransactionScope, Transactions and MSDTC
• Null Value exception thrown, need to cha

Recommend Articles

• DataSet Merging
• Getting deleted child rows for a "S
• Problem in element order - while writtin
• is it possible to interrupt fill method
• mapping issue in ado.net when executeNon
• Where to store SQL server connection str
• Best way to create multiline T-SQL in .N
• [C# 2.0] ControlState
• Asp / Ado databinding to Sql database
• ODBC Wizard can't create insert/update/d
• Sample Code
• Global Caching
• Connecting to SQL Database using Enterpr
• after publish the program, if i wanna ch
• Memory Efficiency of DataTables