使用LINQ和循环结果进行选择时出错 [英] Error when selecting using LINQ and looping results
本文介绍了使用LINQ和循环结果进行选择时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了以下代码:
I have written the following code:
Dim selectedFrame = (From SF In TOCFrames Where SF!Model = cboModel.Text Select SF!Model, SF!Colour, SF!PROS_Design, SF!PROS_Description)
For Each Item In selectedFrame
If Not IsDBNull(Item.Colour) Then
txtColour.Text = Item.Colour
Else
txtColour.Text = ""
End If
If Not IsDBNull(Item.PROS_Design) Then
txtDesign.Text = Item.PROS_Design
Else
txtDesign.Text = ""
End If
If Not IsDBNull(Item.PROS_Description) Then
txtDescription.Text = Item.PROS_Description
Else
txtDescription.Text = ""
End If
Next
哪个通常工作,但目前不工作。我有一条错误消息说:
Which normally works however is not working at the moment. I have an error message that says:
Error 55 'Item' is not declared. It may be inaccessible due to its protection level.
我试图在互联网上搜索一个解决方案,但是没有成功。如果有人能帮助我,那就太棒了!
I have tried to search the internet for a solution, however have been unsuccessful with this. If anyone would help me out then that would be great!
推荐答案
看到这个文章 [ ^ ],它应该指向正确的方向。
See this article[^], it should point you in the right direction.
问题是我有明确的选项,也没有将Item作为对象循环。
谢谢大家的帮助!
The problem was that I had option explicit on and also was not looping Item as object.
Thank you all for your help!
这篇关于使用LINQ和循环结果进行选择时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文