如何使用C#在sql Server 2005中使用旧数据库创建新数据库?

问题描述:



我如何创建新数据库并制作新日志和mdf文件,以从旧数据库中复制一些数据,我必须从C#中执行此操作,还必须从我选择的文件夹中复制一些dotnet exe.

请帮助我.

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.

如果您需要从旧数据库中获取数据并使用该数据库创建新数据库,则可能是两种最简单的方法:
-进行备份 [还原 [ ^ ]作为新数据库
-分离数据库,将其复制并将其附加到其他位置.请参阅:分离和附加数据库 [
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[^]


Google是您的朋友:祝您访问愉快他经常.与在这里发布问题相比,他可以更快地回答问题.

使用您的主题作为搜索词的快速搜索 将这三个作为顶部链接:

使用C#创建SQL Server数据库 [以编程方式创建SQL数据库 [如何使用ADO.NET和Visual C#.NET以编程方式创建SQL Server数据库 [
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.