Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 9th, 2005, 01:04 PM
Authorized User
 
Join Date: Apr 2005
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to merge two datatables?????????

hi

I have two datatables in my program, getting data from datagrid having thousands of records
My requirement is that I have to delete 1 column from first datatable (can be from any position) and insert 3 new columns at the position of the deleted column?
how can i achieve my purpose speedly?

thanx

avats


 
Old July 9th, 2005, 01:22 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Look a look at the methods provided by the DataColumnCollection class:

http://msdn.microsoft.com/library/en...mberstopic.asp
 
Old March 16th, 2006, 10:30 AM
Registered User
 
Join Date: Feb 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To remove a column from a DataTable you can use the code
Private Sub RemoveColumnByName(colName As String)
    Dim cols As DataColumnCollection
    ' Get the DataColumnCollection from a DataTable in a DataSet.
    cols = DataSet1.Tables("Orders").Columns
    If cols.Contains(colName) Then
       If cols.CanRemove(cols(colName)) Then cols.Remove(colName)
    End If
 End Sub
To add a column to a DataTable you can use the code
Private Sub AddColumn()
    Dim cols As DataColumnCollection
    Dim myCol As DataColumn
    ' Get the DataColumnCollection of a table in a DataSet.
    cols = DataSet1.Tables("Orders").Columns
    ' Add a new column and return it.
    myCol = cols.Add("Total",System.Type.GetType("System.Decim al"), _
       "Price + Tax")
    myCol.ReadOnly = True
    myCol.Unique = False
 End Sub
 
Old March 21st, 2006, 08:40 AM
Registered User
 
Join Date: Feb 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use tableView.






Similar Threads
Thread Thread Starter Forum Replies Last Post
DataTables and Visual Studio DeaconKen VB.NET 2002/2003 Basics 1 January 29th, 2007 12:33 PM
Need Help With DataTables visanza Beginning VB 6 1 January 9th, 2007 01:30 PM
Displaying 2 datatables in 1 datagrid muskaanbajaj Classic ASP Databases 5 May 19th, 2005 11:36 AM
2 x DataTables and Datagrid Vince ADO.NET 0 September 22nd, 2003 08:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.