Anders
Anders

Reputation: 12570

Why is my database not being updated with this LINQ query?

Code:

Public Sub UpdateDB()
    Dim db As New linqclassesDataContext
    Dim article = From p In db.articles _
              Where p.id = articlelist.SelectedValue _
              Select p

    article.FirstOrDefault.body = FCKeditor1.Value
    Try
        db.SubmitChanges()
    Catch ex As ChangeConflictException
        fcke_output.Text = ex.Message
    End Try
End Sub

no errors are thrown, but my database value is not updated. Any ideas?

Upvotes: 1

Views: 158

Answers (1)

eglasius
eglasius

Reputation: 36035

Yes, make sure the generated class has the primary key attribute.

Update 1: linq2sql just doesn't behaves well when no primary key is specified - if there isn't one on the table, make sure to specify an appropiate one on the designer

Upvotes: 2

Related Questions