Linq: no update in row

  • Thread starter Thread starter Arjen
  • Start date Start date
A

Arjen

Hi,

Here is my code:

MyDataContext db = new MyDataContext();
Profile profile = db.Profiles.Single(u => u.UserId == userId);

// Edit
profile.Surname = surname;
profile.DateOfBirth = dateOfBirth;
profile.LastUpdate = DateTime.Now;

// Update
db.SubmitChanges();

Here is my situation:
- The data connection works (the user profile gets selected with database
values)
- All input values are new (surname, dateOfBirth, and DateTime.Now)
- I receive no errors, but the row gets not updated for some reasons.

Any ideas why not?

Thanks!
 
Arjen said:
Hi,

Here is my code:

MyDataContext db = new MyDataContext();
Profile profile = db.Profiles.Single(u => u.UserId == userId);

// Edit
profile.Surname = surname;
profile.DateOfBirth = dateOfBirth;
profile.LastUpdate = DateTime.Now;

// Update
db.SubmitChanges();

Here is my situation:
- The data connection works (the user profile gets selected with database
values)
- All input values are new (surname, dateOfBirth, and DateTime.Now)
- I receive no errors, but the row gets not updated for some reasons.

Any ideas why not?

Thanks!


Aha, I forgot to set the primary key. Stupid!
 

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

Back
Top