我不断收到试图执行这些代码时这个错误,甚至放置CTYPE围绕价值和其定义为双后键入“双是不是有效?转换
Private Sub GridView1_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
' The deletion of the individual row is automatically handled by the GridView.
Dim dbDelete As New pbu_housingEntities
' Remove individual from the bed.
Dim occupant As String = GridView1.Rows(e.RowIndex).Cells(2).Text
Dim room As String = GridView1.Rows(e.RowIndex).Cells(5).Text
Dim building As String = GridView1.Rows(e.RowIndex).Cells(4).Text
Dim find_id = From p In dbDelete.Residents _
Where p.person_name = occupant _
Select p
Dim remove_bed = From p In dbDelete.Beds _
Where p.occupant = find_id.FirstOrDefault.id _
Where p.room = room _
Where p.building = building _
Order By p.id Descending _
Select p
remove_bed.First.occupant = CType(0, Double)
dbDelete.SaveChanges()
' Increase number of open spaces in room.
Dim update_occupancy = From p In dbDelete.Rooms _
Where p.room1 = room
Where p.building = building _
Select p
update_occupancy.First.current_occupancy = update_occupancy.First.current_occupancy - 1
dbDelete.SaveChanges()
End Sub
哪条线是扔? – JaredPar 2011-04-05 18:19:23
你确定CType行是错误的地方吗?在下一个LINQ语句中使用它之前,您甚至不会检查find_id是否有值。这可能是一个问题。 – 2011-04-05 18:23:55