Creating a copy of DB using script

Posts   
 
    
Yash
User
Posts: 20
Joined: 07-Jan-2010
# Posted on: 11-Mar-2010 07:04:38   

Hi,

The requirement is to create a COPY of DB that is mapped to my application (say projA) and using LLBLGEN created C# project as its DB layer. I need a functionality of creating a copied DB that need to be tied to some other C# application(Say projB) at run time, each time respective application starts. Now, can we generate SQL scripts(structure with data) using LlBlGen to create copied DB for projB? Also this will use DB Layer as tied with projA.

Please suggest.

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 11-Mar-2010 11:39:38   

I'm sorry but I'm not following. Why do you need to copy the database using LLBLGen.

I would say you should have the database sql script ready in a file so you can use it at runtime to create the database using normal ADO.NET or calling the osql comand line tool.

Yash
User
Posts: 20
Joined: 07-Jan-2010
# Posted on: 11-Mar-2010 11:52:07   

Walaa wrote:

I'm sorry but I'm ...tool.

Yes, you are right, but the thing is that myApplication needs a fresh DB(copied with data) each time it starts and tend to make changes. After that changed DB needs to be synchronize with old copy. This will be repeated n times, so all process should be carried out through code only as a background process(c# in my case). This feature is very critical for my application. Suggestions are welcomed, if any.

Thanks for replying.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 11-Mar-2010 12:06:54   

So the problem is the data. You can have the start script that can be executed to build an empty database. Then you should build your own utility to ready records from the old database using LLBLGen code and then insert them in the new one.

Yash
User
Posts: 20
Joined: 07-Jan-2010
# Posted on: 11-Mar-2010 12:35:41   

Walaa wrote:

So the ...

Yes, you are correct. Suppose I create the DDL script, then does LlBlGen provide any facility to copy whole DB(only data) to the an empty one in one go? Please suggest.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 11-Mar-2010 12:45:33   

Nope. This is better done by BulkInsert (sometimes called BulkCopy).

Please google for these terms. e.g. link: http://www.codeproject.com/KB/database/SqlBulkCopy.aspx

Yash
User
Posts: 20
Joined: 07-Jan-2010
# Posted on: 11-Mar-2010 12:50:22   

Walaa wrote:

Nope. This is better done...

Ok. Thanks for the url, will check and try if this can help me in preparing a solution.