ado.net Concurrency violation
Posted
by Bicubic
on Stack Overflow
See other posts from Stack Overflow
or by Bicubic
Published on 2010-06-07T02:50:51Z
Indexed on
2010/06/07
2:52 UTC
Read the original article
Hit count: 321
My first time using ADO.net. Trying to make database of Users.
First I populate my DataSet:
adapter.AcceptChangesDuringFill = true;
adapter.AcceptChangesDuringUpdate = true;
adapter.Fill(dataset);
To create a user:
User user = new User();
user.datarow = dataset.Users.NewUsersRow();
user.Name = username;
user.PasswordHash = GetHash(password);
user.Rights = UserRights.None;
users.Add(user);
dataset.Users.AddUsersRow(user.datarow);
adapter.Update(dataset);
When a user property is modified:
adapter.Update(dataset);
Creation by itself is fine. If I take an existing user and make multiple changes, fine. Multiple creations in a row, fine. Creation followed by a property change, I get this: "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records."
Any ideas?
© Stack Overflow or respective owner