如何使用vb.net 2019从访问数据库中关系的另一列表中查看特定列的所有数据主表

问题描述 投票:0回答:1

[这是我在SQL查询中的问题,结果已成功将数据网格中的数据加载为SL_No(2,4,5),但表Pairing中缺少一些数据,例如(1,2,3,4,5, 6)在关系表数据不可用的情况下,例如Receipt表中的(1,3,6)。

Private Sub BtnView_Click(sender As Object, e As EventArgs) Handles btnView.Click

    Dim Sql as String = "Select Pairing.Ledger_Index, Pairing.Fr_Customer_no, Pairing.Fr_Customer_nm, Receipt.Dt_Entry, Receipt.Price from Pairing INNER JOIN Receipt ON Pairing.Fr_Customer_no = Receipt.Sub_No WHERE (((Pairing.Ledger_Address)='" & cmbList.Text & "'))""

    If RdoLedger.Checked=True Then
       DatagridView_Load("sql",DatagridView1)
    End If

End Sub

Public Function DatagridView_Load(ByVal Sql As String, ByVal Model As DataGridView)
    Try
        If con.State = ConnectionState.Open Then
            con.Close()
        End If
        Model.DataSource = Nothing
        Dim da As New OleDbDataAdapter(Sql, con)
        Dim dt As New DataTable
        dt.Clear()
        da.Fill(dt)
        If IsDBNull(dt) = False Then
            Model.DataSource = (dt)
            con.Close()
        Else
            Model.DataSource = Nothing
            con.Close()
        End If

    Catch ex As Exception
        MsgBox("ERROR : " & ex.Message.ToString)
    End Try
    Return True
End Function
sql vb.net ms-access-2007 visual-studio-2019
1个回答
1
投票

[谢谢您的尸体回复我,因为我不会理解这个问题的答案。这是一些简单的答案。在这里,我需要第一张桌子的所有记录。所以我的查询应该是=来自配对INNER JOIN收据更改为来自配对left JOIN收据成功获得我的结果

© www.soinside.com 2019 - 2024. All rights reserved.