LINQ - Insert or Update if Record Exist RRS feed

  • Question

  • User-908392717 posted

    I can get LINQ to insert with no problem, I would like for it to Insert only if its a new record .. I'm trying to figure out the way to do this .. do I use IF Statements or is there an easier way .. this is the code I'm using for Insert

    Protected Sub Insert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Insert.Click

    Dim db As New DataClassesDataContext

    Dim w As New UserStatus With {.Value = "Week 1", .UserID = User.Identity.Name}




    End Sub


    Thanks for Any Help

    Sunday, September 14, 2008 2:39 PM

All replies

  • User-990694832 posted


    Try  doing a select statement before the insert

    cant a person set up the table with no duplicates as a constraint? 

    Hope this hels


    Monday, September 15, 2008 8:40 AM