Click here to Skip to main content
15,914,444 members
Please Sign up or sign in to vote.
2.67/5 (3 votes)
See more:
hi there,

How i can create a new database and make new log and mdf files copying some data from old one and i have to do this from C# and also copy some dotnet exe from the folder of my choice.

please help me.
Posted
Updated 1-Jan-12 21:04pm
v2
Comments
OriginalGriff 2-Jan-12 3:46am    
Reason for my vote of one: too lazy to use google.
Amir Mahfoozi 2-Jan-12 10:17am    
You can attach to that deployed database.

If you need to get the data from an old database and using that create a new one, two perhaps easiest ways are:
- Take a BACKUP[^] and then RESTORE[^] it as a new database
- Detach the database, copy it and attach it to somewhere else. See: Detaching and Attaching Databases[^]
 
Share this answer
 
Comments
Espen Harlinn 2-Jan-12 19:03pm    
Good advice :)
Wendelius 3-Jan-12 0:24am    
Thanks :)
Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...

A very quick search using your subject as the search term gave these three as the top links:

Create a SQL Server Database Using C#[^]
Create a SQL Database Programmatically[^]
How To Create a SQL Server Database Programmatically by Using ADO.NET and Visual C# .NET[^]

In future, please try to do at least basic research yourself, and not waste your time or ours.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900