tags:

views:

95

answers:

1

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?

+2  A: 

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

eglasius
being pretty new to LINQ, I am not entirely sure what the "generated class" could be. could you elaborate please? thanks :)
Anders
Open the dbml file you created, and view the properties of the primary key field. If this isn't set, SubmitChanges will silently fail.
Adam Lassek
excellent, thanks to both of you!
Anders