【问题标题】:Fetching specific data through .Select in vb通过.Select在vb中获取特定数据
【发布时间】:2014-01-28 05:16:54
【问题描述】:

我从vbForums 获得此代码,其中在Floor 列中获得不同的楼层值。 (我用它来填充组合框)

Dim names = From row In FbuildingSettings.camButtonDtable.AsEnumerable() Select row.Field(Of Integer)("Floor") Distinct

我在想,有没有办法在选定的Building另一列)中获得不同的楼层。类似于:
SELECT Distinct Floor FROM Building = 'Megamart'
抱歉,如果线路中断,则不擅长此操作。但可能是这样的。我需要的是,获取我选择的Building 中的所有Floor 数据。假设我想要 megamart,然后将项目添加到组合框中,这些项目是来自 megamart 的Floor 数据。

更新我试过这个:

Dim names = From row In FbuildingSettings.camButtonDtable.AsEnumerable() _
                Select row.Field(Of String)("Building") & row.Field(Of Integer)("Floor") Distinct

但它似乎只连接了来自建筑物 + 楼层的数据。 (megamart1)

【问题讨论】:

    标签: sql .net vb.net select


    【解决方案1】:
    Dim names = From row In FbuildingSettings.camButtonDtable.AsEnumerable() where row.Building = 'Megamart' Select row.Field(Of Integer)("Floor") Distinct
    

    请检查一下......

    【讨论】:

    • 'Dim names = From row In FbuildingSettings.camButtonDtable.AsEnumerable() where row.Building.contains('Megamart') Select row.Field(Of Integer)("Floor") Distinct'跨度>
    • row.Building 上没有语法 - 这是非法的。
    【解决方案2】:

    这个怎么样:

    Dim floors = From row In FbuildingSettings.camButtonDtable.AsEnumerable() _
                 Where row.Field(Of String)("Building").Contains("Megamart") _
                 Select row.Field(Of Integer)("Floor") Distinct
    

    【讨论】:

    • 我正要编辑 Anto 对此的回答。总之谢谢
    • 几乎我已经做到了,只是语法错误......老实说,我从未使用过 linq 或任何 OR 映射工具,这是我的第一个工作......我用来自 Stackoverflow 的一些输入......
    猜你喜欢
    • 1970-01-01
    • 2010-09-16
    • 1970-01-01
    • 1970-01-01
    • 2015-11-21
    • 2018-01-18
    • 2011-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多