Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 如何合并以2种不同方式构建的2个DataView?_Vb.net_List_Dataview - Fatal编程技术网

Vb.net 如何合并以2种不同方式构建的2个DataView?

Vb.net 如何合并以2种不同方式构建的2个DataView?,vb.net,list,dataview,Vb.net,List,Dataview,我不是一名c#开发者,我发现自己正在与一个巨大的c#应用程序一起工作……拥抱 现在,我正试图用更多以不同方式“创建”的数据填充现有的DataGrid…让我向您展示我的意思 这是如何生成现有DataView的: Dim lDataSet As System.Data.DataSet Dim lSqlCommand As New System.Data.SqlClient.SqlCommand Dim lConvert As New PeoplePlanner.Common.Data.Convert

我不是一名c#开发者,我发现自己正在与一个巨大的c#应用程序一起工作……拥抱

现在,我正试图用更多以不同方式“创建”的数据填充现有的DataGrid…让我向您展示我的意思

这是如何生成现有DataView的:

Dim lDataSet As System.Data.DataSet
Dim lSqlCommand As New System.Data.SqlClient.SqlCommand
Dim lConvert As New PeoplePlanner.Common.Data.Convert

lSqlCommand.CommandType = CommandType.StoredProcedure
lsqlCommand.CommandText = "AccessIntegrationEmployeeInboundSearch"

lDataSet = objDatabase.GetDataSet(lSqlCommand)

If Not IsNothing(lDataSet) Then
    objDataView = lDataSet.Tables(0).DefaultView
End If
这段代码中可能缺少一些东西,但希望它足以提供一个概述。它使用存储过程(SP)从数据库中获取一些数据,并在“lDataSet”中返回结果,然后执行“objDataView=lDataSet.Tables(0.DefaultView)”

现在,我要“合并”的新数据具有相同的字段,但它不是SP的响应,而是我创建的一个操作的响应,该操作返回OnBoardingEmployee列表(我们这样称呼它),如果我只想正确显示该列表中的数据,我会这样做:

 Dim lDataView As System.Data.DataView

 Dim op = CoreInjector.Inject(Of IGetAllDataHubIncomingMessagesToBeProcess).Execute()
 lDataView = Common.Detail.DataGridOperationHelper.ConvertToDataTable(op.OnBoardingEmployee).DefaultView

 objDataView = lDataView
其中:

  • op包含一个OnBoardingEmployee列表,其字段与现有表相同
  • lDataView基本上与objDataView相同,这就是为什么在最后一步中我分配objDataView=lDataView
现在我想合并,加入,添加,随便什么 为第一个表创建的objDataView:
objDataView=lDataSet.Tables(0).DefaultView

我后来创建了一个:

 lDataView = Common.Detail.DataGridOperationHelper.ConvertToDataTable(x.OnBoardingEmployee).DefaultView
我该怎么做?:'(

它们具有相同的数据结构,或者更好地说,它们使用相同的视图

感谢您的帮助:)

我已经让它工作了:)这是我的实现:

        Dim employeeJSONTable As DataTable
        Dim employeeExistingTable As DataTable
        Dim myDataRow As DataRow
        Dim employeeID As Integer

        if Request.QueryString.Get("Function") = "HubInbound" then
            Dim employeeJSONList = CoreInjector.Inject(Of IGetAllDataHubIncomingMessagesToBeProcess).Execute()
            employeeJSONTable = Common.Detail.DataGridOperationHelper.ConvertToDataTable(employeeJSONList.OnBoardingEmployee)
            employeeJSONTable.PrimaryKey = New DataColumn(){ employeeJSONTable.Columns("EmployeeID")}
        End If

        lDataSet = objDatabase.GetDataSet(lSqlCommand)
        employeeExistingTable = lDataSet.Tables(0)

        For Each row As DataRow In employeeExistingTable.Rows

            employeeID = row.Item("EmployeeID")

            myDataRow = employeeJSONTable.Rows.Find(employeeID)

            if (myDataRow Is Nothing) then
                employeeJSONTable.ImportRow(row)
            End If

        Next row

        If Not IsNothing(employeeJSONTable.DefaultView) And Request.QueryString.Get("Function") = "HubInbound" Then
                objDataView = employeeJSONTable.DefaultView
        Elseif Not IsNothing(lDataSet) Then
                objDataView = lDataSet.Tables(0).DefaultView
        End if

首先,让你自己熟悉一下。