Merging data between an Untyped and Typed Dataset

wsyeager

Well-known member
Joined
Apr 10, 2003
Messages
140
Location
Weston, FL
Does anybody know how you can merge data from an Untyped Dataset into a specific table of a Strongly Typed Dataset?

Check out the following function:
<code>


Public Function GetCustomerss() As dstCustomers

Try

Dim dst As New DataSet

Dim tablenames() As String = {"Customers"}

SqlHelper.FillDataset(SqlDataAdapter1.SelectCommand, dst, tablenames)

DstCustomers1.Merge(dst)

Catch ex As Exception

Throw (ex)

Finally

SqlDataAdapter1.Dispose()

SqlConnection1.Close()

End Try

Return DstCustomers1

End Function
</code>

Suppose that dataset "DstCustomers1" has two tables in it (Customers and Orders). When you perform the following code,
<code>


DstCustomers1.Merge(dst)
</code>
if DstCustomers1 has only one table, it will perform the merge with no problem. However, how can you specifically merge the contents of the Untyped dataset into a specific table of DstCustomers1 (like into the Customers or Orders table)?
 
Possible solution

The only thing I can think of that would accomplish this is the following code:

<code>
Dim dr As DataRow
For Each dr In dst.Tables(0).Rows
DstCustomers1.Customers.ImportRow(dr)
Next
</code>

If anyone has anything more efficient, just let me know....
 
Back
Top