Solved

How to copy from one  datable to another in Vb.net

Posted on 2011-09-16
9
318 Views
Last Modified: 2012-05-12
I need to copy one datatable (dt) to another datatble (dt2), dataset or Data view in VB.NET.
  and I want to skip first  first row  in dt, and copy rest of the rows in dt2.
0
Comment
Question by:Ammar Iqbal
9 Comments
 
LVL 16

Accepted Solution

by:
disrupt earned 167 total points
Comment Utility
0
 
LVL 1

Author Comment

by:Ammar Iqbal
Comment Utility
This thing I know, but i do not want to copy all data. I need to skip first row  , and copy rest of the rows
0
 
LVL 16

Expert Comment

by:disrupt
Comment Utility
in the copy you can delete the first row as so:

http://msdn.microsoft.com/en-us/library/feh3ed13(v=VS.100).aspx
0
 
LVL 16

Expert Comment

by:disrupt
Comment Utility
You can either delete the first row using example above  or use LINQ to manipulate the data in the datatable as so:

http://dotnetarchitect.wordpress.com/2009/03/18/using-linq-to-manipulate-data-in-datasetdatatable/
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 1

Author Comment

by:Ammar Iqbal
Comment Utility
i am using .NET framework 2.0, and linq is not included in it
0
 
LVL 16

Expert Comment

by:disrupt
Comment Utility
you should be able to still remove the first row...using the other example...
0
 
LVL 16

Expert Comment

by:disrupt
Comment Utility
0
 
LVL 15

Assisted Solution

by:x77
x77 earned 166 total points
Comment Utility
Use ImportRow For each Row you can copy:

    Dim Rows = T1.Select
    For N = 1 To Rows.Length - 1
        t2.ImportRow(Rows(N))
    Next

This copy not deleted rows (T1.Select), skiping First row.

Note that you can Filter or Sort using Select.
Note that this method also copy RowState (DataRowVersion.Current and DataRowVersion.Original)
0
 

Assisted Solution

by:soniczoo
soniczoo earned 167 total points
Comment Utility

Dim dt2 As DataTable = dt.Clone()
dt2.Rows.RemoveAt(0)
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now