how to copy records from one table to another

sabdul_haq

New member
Joined
Aug 7, 2005
Messages
2
Programming Experience
1-3
Hi,
I'm a new member, I need some help.
Can anyone tell how to copy records from one table to another table with the same columns using dataset and dataadapter.I'm using MS Access and VB .Net.

i'm trying to use importrow method as follows but its not working :

"row" is from the first table.

ds.Tables("TargetTable").ImportRow(row)
.... proper insert query
da.update(ds,"TargetTable")

i'm also trying to copy the required row directly to the target table in dataset but it says
"this row already belongs to another table".

can anyone help.Its quite urgent

regards

Abdulhaq
 
Last edited:
I'm not sure as i'm not dataset specialist but i would suggest using a simple query to do this, instead of using any of the classes.

a simple query to copy a Table from one to Another will look like this:

SELECT Table1.* INTO TABLE1 IN 'C:\test.mdb' FROM Table1;

You will have to run this query using the OleDBCommand Object.



cheers ;)
 
Last edited:
Hi,
Thanx for the quick reply, finally i solved the problem actually i was passing wrong Insert query thats why its was giving error "ODBC Too few parameters expected 5".

These methods worked

DataTable.LoadDataRow( _
ByVal values() As Object, _
false ) As DataRow
And

DataRowCollection.Add(object())
DataRowCollection.Add(DataRow)
Then calling the proper insert Command from DataAdapter

Bye for now
Abdulhaq
 
Back
Top