Hi,
I have two tables:
1. SALESTABLE
2. RECEIPTSTABLE
I am now retrieving data of the above tables in separate datagridviews using the below code which is working fine.
But I need a query that fetches both tables' data in one datagridview with one extra virtual column "BALANCE" as shown in the screenshots (attached).
Looking forward to your kind support.
I have two tables:
1. SALESTABLE
2. RECEIPTSTABLE
I am now retrieving data of the above tables in separate datagridviews using the below code which is working fine.
Code:
Private Sub LoadSales()
Dim StrSql As String = "Select CUSTNO, CUSTNAME, INVNO, INVDATE, Sum(INVAMT) As INVAMT from SALESTABLE Where [CUSTNO] LIKE '" & txtSearchCustNo.Text & "' Group By CUSTNO, CUSTNAME, INVNO, INVDATE Order By CUSTNO ASC"
Dim dt As New DataTable
If Not DAL.ExecuteSql(dt, StrSql, Msg) Then MsgBox(Msg, MsgBoxStyle.Exclamation, "Error") : Exit Sub
Me.dgvSales.DataSource = dt
If dt Is Nothing Or dt.Rows.Count <= 0 Then
Exit Sub
End If
End Sub
Code:
Private Sub LoadReceipts()
Dim StrSql As String = "Select CUSTNO, CUSTNAME, RECEIPTNO, RECEIPTDATE, RECEIVEDAMT from RECEIPTSTABLE Where [CUSTNO] LIKE '" & txtSearchCustNo.Text & "' Order By RECEIPTNO ASC"
Dim dt As New DataTable
If Not DAL.ExecuteSql(dt, StrSql, Msg) Then MsgBox(Msg, MsgBoxStyle.Exclamation, "Error") : Exit Sub
Me.dgvReceipts.DataSource = dt
If dt Is Nothing Or dt.Rows.Count <= 0 Then
Exit Sub
End If
End Sub
Looking forward to your kind support.