当前位置:编程学习 > C#/ASP.NET >>

数据集关联问题

   我用vs2005 建立了一个数据集,里面包含Login(字段:CodeID),ProductCount(字段:CodeID,Product,Count)两张数据

表,建立了关联关系,父表为Login,子表为ProductCount,关联的键为CodeID,现在想实现的是通过Login表的CodeID,找到表

ProductCount中符合CodeID的具体信息。
      表信息:
           Login:
                       CodeID
                         1
                         2
                         3
           ProductCount: 
                        CodeID     Product    Count
                          1        计算机      4
                          1        电脑        5
代码如下
        Dim ds As New DataSet
        Dim str As String = ""
        str = "select * from Login where CodeID=1 "
        adapter = New SqlDataAdapter(str, con)
        adapter.Fill(ds, "Login")
        在Login表中满足条件的信息为一行,我想通过关联关系如何直接找到在ProductCount满足条件的那两行呢,代码应该如何写呢?
        --------------------编程问答-------------------- 这个问题简单,你使用什么数据库?
str = "select * from Login where CodeID=1“ 你可以先就在这一步完成表关联。
--------------------编程问答--------------------   我用的是sql2005
补充:.NET技术 ,  VB.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,