【问题标题】:Datatables VB.Net数据表 VB.Net
【发布时间】:2013-09-19 12:18:20
【问题描述】:

我有 2 个数据表

表 1(Type6)有字段:StopNo

表 2(站名)包含字段:StopNo、名称

我想要做的是加入2个表,所以在sql中它会是这样的:

SELECT DISTINCT Type6.STOPNO, StationName.NAME FROM Type6 JOIN StationName on StationName.STOPNO=Type6.STOPNO order by NAME"

如何使用包含相同信息的 2 个数据表执行此操作?

【问题讨论】:

标签: vb.net datatable


【解决方案1】:

...让我知道这是否有效...

    Dim Result = (From tp6 As DataRow In Type6
             Join stNm As DataRow In StationName
             On tp6.Item("STOPNO") Equals stNm.Item("STOPNO")
             Select x = New With {.STOPNO = tp6.Item("STOPNO"), .NAME = stNm.Item("NAME")}).Distinct

【讨论】:

  • 感谢约翰,到达那里。我使用了它,然后添加了 ComboBox1.DataSource=Result.ToList 并得到以下信息:{ STOPNO = S12345,NAME = STATION 1}。不知道我是怎么得到“S12345 - STATION 1”的
  • 通过将 SELECT 更改为来对其进行排序:选择 tp6.Item("STOPNO") & " - " & stNm.Item("NAME")).Distinct。再次感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-20
  • 2011-10-03
  • 2011-07-11
  • 2016-02-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多