【发布时间】:2010-07-15 21:25:07
【问题描述】:
我有以下代码:
Dim dbHousing As New dcHousingDataContext
Dim pullresidents = From p In dbHousing.webResidents _
Select p.dorm_building, p.dorm_room, p.occupantnum _
Order By dorm_building, dorm_room
Dim j as integer = 1
Dim previous As String = ""
For Each row In pullresidents
If previous = "" Then
Dim wResident As New webResident
wResident.occupantnum = j
dbHousing.SubmitChanges()
j = j + 1
previous = row.dorm_building & " " & row.dorm_room
Else
If previous = row.dorm_building & " " & row.dorm_room Then
Dim wResident As New webResident
wResident.occupantnum = j
dbHousing.SubmitChanges()
j = j + 1
Else
Dim wResident As New webResident
j = 1
wResident.occupantnum = j
dbHousing.SubmitChanges()
j = j + 1
previous = row.dorm_building & " " & row.dorm_room
End If
End If
Next
当我运行它时,查看调试器一切看起来都不错,但是当我检查它应该插入的数据库表时 - 列值(对于 occupantnum)没有改变 - 它们都仍然为空!
不确定这是否相关,但请注意,我现在已将 j 更新为明确为整数。我在调试时注意到 wResident.occupantnum 显示为类型“整数?” - 但这似乎没有任何区别 - 当我重新运行它时,它仍然显示 Type "Integer?"
【问题讨论】:
-
什么是后端服务器? SQL 服务器?甲骨文?
-
SQL Server 2008 在后端。
标签: asp.net sql vb.net linq-to-sql