Copying data to another database

Posts   
 
    
jovball
User
Posts: 435
Joined: 23-Jan-2005
# Posted on: 11-Jul-2012 13:59:30   

I am trying to copy some data from one database to another. I fetch an EntityCollection from the first database. This is successful.

Next I open a connection to the second database and attempt to save (insert) each of the entities in that database. SaveEntity returns true but the data is not inserted.

Is this a code problem or something else?


Using dataAdapter As New DataAccessAdapter("SecondDatabaseConnectionStringHere")
            For Each item As IEntity2 In dataCollection
                item.IsNew = True
                logger.Debug("Saved: {0}", dataAdapter.SaveEntity(item))
            Next
End Using

DvK
User
Posts: 318
Joined: 22-Mar-2006
# Posted on: 11-Jul-2012 18:40:24   

You have to reset the complete entity by setting the IsChanged property (to True) from all fields as well....

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 11-Jul-2012 19:42:04   

Also make sure IsDirty is set to true for each entity.