wsyeager Posted September 7, 2005 Posted September 7, 2005 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)? Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
wsyeager Posted September 7, 2005 Author Posted September 7, 2005 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.... Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.