GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Microsoft  >  Ado.NET
Next Question 
 Ado.NET  |  Question 1 of 31    Print  
How to copy the contents from one table to another table and how to delete the source table in ado.net?

  
Total Answers and Comments: 22 Last Update: October 29, 2009   
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: BalaSM
 

hi

it is possible

DataSet ds;

sqlAdap.Fill(ds);

Datatable dt = ds.Tables[0].copy();

//now the structure and data are copied into 'dt'

ds.Tables.remove(ds.Table[0]);

//now the source is removed from the 'ds'



Above answer was rated as good by the following members:
surendra_sahu786, kapilsanchihar
  Sorting Options  
  Page 1 of 3   « First    1    2    3    >     Last »  
September 12, 2005 05:37:34   #1  
jagadeesh        

RE:
cleart and fill
 
Is this answer useful? Yes | No
March 02, 2006 13:46:55   #2  
ashishmisra78 Member Since: March 2006   Contribution: 4    

RE: How to copy the contents from one table to another...
How to copy the contents from one table to another table and how to delete the source table in ado.net?

 
Is this answer useful? Yes | No
March 10, 2006 22:59:46   #3  
Puli        

RE: How to copy the contents from one table to another...
May be there is a better way but you can generating a datatable from source and load it to destination if the process is successful execute the drop table query.
 
Is this answer useful? Yes | No
May 04, 2006 11:01:59   #4  
S Kumar        

RE: How to copy the contents from one table to another...

To Copy you use: NewTable DS(tableName).copy

To Delete Use .Clear


 
Is this answer useful? Yes | No
May 11, 2006 07:34:43   #5  
Sathyavathi        

RE: How to copy the contents from one table to another...

Hi

You can do it in ado.net 2.0 using SqlBulkCopy.

Regards

Sathyavathi


 
Is this answer useful? Yes | No
June 12, 2006 04:03:02   #6  
Vivek        

RE: How to copy the contents from one table to another...

Hi

You have to use dataset as datasource. and when you retrieve data in dataset use clone() method to make copy of one table to another.

Vivek B.


 
Is this answer useful? Yes | No
June 22, 2006 09:29:29   #7  
rahul kulshrestha        

Ans: How to copy the contents from one table to another...

Hi

I use reader to hold the data. and this reader is passed to sqlbulkcopy to write on the destination server.

if u want further information then mai me on my id.

strSql SELECT * FROM authers

CommandSourceData New SqlCommand(StrSql SourceConn)

reader CommandSourceData.ExecuteReader()

Using bcp _

New SqlClient.SqlBulkCopy(DesConnString)

bcp.DestinationTableName _

authers

' Write from the source to the destination.

bcp.WriteToServer(reader)

End Using

reader.Close()


 
Is this answer useful? Yes | No
July 27, 2006 02:14:06   #8  
areef        

RE: How to copy the contents from one table to another...
ThanQ
 
Is this answer useful? Yes | No
August 02, 2006 06:03:06   #9  
BalaSM        

RE: How to copy the contents from one table to another...

hi

it is possible

DataSet ds;

sqlAdap.Fill(ds);

Datatable dt ds.Tables[0].copy();

//now the structure and data are copied into 'dt'

ds.Tables.remove(ds.Table[0]);

//now the source is removed from the 'ds'


 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    
October 17, 2006 16:12:21   #10  
pixelgrease Member Since: October 2006   Contribution: 1    

RE: How to copy the contents from one table to another...

Must use Copy not Clone. Clone duplicates the structure but does not copy data.


 
Is this answer useful? Yes | No
  Page 1 of 3   « First    1    2    3    >     Last »  


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape