ASP.NET LINQ to Delete Rows

Posted by Tyler on Stack Overflow See other posts from Stack Overflow or by Tyler
Published on 2010-04-30T01:20:09Z Indexed on 2010/04/30 1:27 UTC
Read the original article Hit count: 341

Filed under:
|
|
|
Dim db As New SQLDataContext
Try
    Dim deleteBoatPics = (From boat In db.Photos
                          Where boat.boatid = id)
    db.Photos.DeleteOnSubmit(deleteBoatPics)
    db.SubmitChanges()
Catch ex As Exception
End Try

I'm getting an error that says: Unable to cast object of type 'System.Data.Linq.DataQuery`1[WhiteWaterPhotos.Photo]' to type 'WhiteWaterPhotos.Photo'.

I have two separate db.SubmitChanges() because when the button is pressed, I have it delete the records from 1 table, and then the next.

I'm lost, can someone help me out?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about LINQ