我想寫一個LINQ查詢比較數據庫中的整數值與整數變量。這不起作用。我可以比較文本值,但比較整數返回null。在VB.net比較整數LINQ查詢
Private Sub txtRoomNum_TextChanged(sender As Object, e As EventArgs) Handles txtRoomNum.TextChanged
If Val(txtRoomNum.Text) > 99 Then
Dim intRoomNum As Integer
intRoomNum = Val(txtRoomNum.Text)
Dim RoomData = (From Rooms In BadermanIslandDataSet.Rooms
Where Rooms.HotelID = intHotelID).SingleOrDefault
''Where Rooms.HotelID = intHotelID And Rooms.RoomNumber = intRoomNum
Try
txtTest.Text = RoomData.RoomID
Catch ex As Exception
txtTest.Text = "null"
End Try
End If
End Sub
打開選項嚴格。 'intRoomNum = Val(txtRoomNum.Text)'將一個Double賦值給一個整數 – Plutonix
我的問題在於查詢本身。它的當前形式是將Rooms.HotelID與intHotelID進行比較。這給了我一個空值。我嘗試過直接輸入數字,但仍然無效。 – Stephanie
打開選項嚴格,你會發現更多的麻煩 – Plutonix