Copy Data between 2 entities or Databases

Posts   
 
    
dmitriysk
User
Posts: 1
Joined: 18-May-2006
# Posted on: 18-May-2006 23:43:10   

I am trying to retrieve data from one database and store to another DB. Two data bases have same structure( same tables), but database names are different. I have generated two projects, one for each database.

I got EntityObjet1 (with many children objects under) populated from DB1. Now I need to store data from EntityObjet1 to DB2. I tried copying data to EntityObjet2 by using EntityObjet1.XmlWrite / EntityObjet2.XmlRead, but non of methods (compact xml or default xml output ) work. It gives me an error or EntityObjet2 is not being populated with new data.

Is it possible to change Connection string or some thing to make EntityObjet1 to save to DB2 without involving EntityObjet2?

Is there ANY solution to this problem?

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 19-May-2006 09:23:45   

When you read an entity, it's not marked as dirty/changed. So you should set the Field object's in the entity.Fields collection to changed by setting their IsChanged property to true and the entity.Fields.IsDirty flag to true as well. If you want to insert the entity in the other db, set entity.IsNew to true as well.

Though, I'm not sure which type the DB is, but if it's SqlServer, copying data is often way faster using DTS services which uses raw bulk export/import of data.

Frans Bouma | Lead developer LLBLGen Pro