简体   繁体   English

如何合并 2 Dataview vb .net

[英]How to merge 2 Dataview vb .net

i want to merge 2 dataview the first have and Code,Name,credit, 0 on debit and the second have Code,Name,0 on credit, debit .我想合并 2 个数据视图,第一个有和 Code,Name,credit, 0 on debit,第二个有 Code,Name,0 on credit, debit。 i want to merge the line of the first with the line of the second to get a dataview that have 1 line : code,name,Credit,debit我想将第一行与第二行合并以获得具有 1 行的数据视图:代码、名称、信用、借记

Sub Facture_old_Getdata()子 Facture_old_Getdata()

    Dim sRs, sRs1 As String

    sRs = " select CodeClt,client , Sum(MontantTTc) As Credit , Cast('' As Double ) As Debit " _
         & "from LV_Fact_CLient " _
         & "where 1=1 and Codeclt ='" & TxtCodeClient.Text & "'" _
         & "group by Codeclt,Client"


    Rsdata = New DataView

    Rsdata = c_DataSql.fGet_Data_ViewAccess(sRs)



    sRs1 = "select Codeclt,Client , Cast('' As Double) As Credit , SUM(Montant) As Debit " _
        & " from Gestionreg " _
        & "where 1=1 and Codeclt ='" & TxtCodeClient.Text & "'" _
        & "group by Codeclt,Client"

    Rsdata1 = New DataView

    Rsdata1 = c_DataSql.fGet_Data_ViewAccess(sRs1)


    Rsdata1.Table.Merge(Rsdata.Table, False, MissingSchemaAction.Ignore)

End Sub

I think your problem has less to do with vb.net than with SQL.我认为您的问题与 vb.net 的关系比与 SQL 的关系小。 In this case UNION is your friend.在这种情况下,UNION 是您的朋友。 You can find more here: https://docs.microsoft.com/de-de/sql/t-sql/language-elements/set-operators-union-transact-sql?view=sql-server-ver15您可以在此处找到更多信息: https : //docs.microsoft.com/de-de/sql/t-sql/language-elements/set-operators-union-transact-sql?view=sql-server-ver15

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM