如何使用C#复制一个MS SQL 2000数据库编程?如何使用、数据库、SQL、MS

2023-09-05 23:45:37 作者:性感的小禽兽

我需要从一个数据库复制几个表到另一个SQL Server 2000中,使用C#(VS 2005)。该呼叫需要进行参数设置 - 我需要能够通过在数据库中的名称而我将要复制这些表

I need to copy several tables from one DB to another in SQL Server 2000, using C# (VS 2005). The call needs to be parameterized - I need to be able to pass in the name of the database to which I am going to be copying these tables.

我可以使用DTS与参数,但我找不到任何样品code,这是否从C#。

I could use DTS with parameters, but I can't find any sample code that does this from C#.

另外,我可以只使用

drop table TableName
select * into TableName from SourceDB..TableName

,然后重建索引等等 - 但是这是真的缺憾

任何其他的想法?

谢谢!

推荐答案

对于SQL Server 7.0和2000年,我们有SQLDMO这一点。对于SQL Server 2005中存在SMO。这允许你做pretty的多少有关的一切管理数据库,脚本对象,列举数据库,等等。这是更好,国际海事组织,不是自己一个滚你自己的做法。

For SQL Server 7.0 and 2000, we have SQLDMO for this. For SQL Server 2005 there is SMO. This allows you do to pretty much everything related to administering the database, scripting objects, enumerating databases, and much more. This is better, IMO, than trying a "roll your own" approach.

SQL 2000: 开发SQL-DMO应用程序

SQL 2000: Developing SQL-DMO Applications

传输对象

SQL 2005: 这里是SMO主页: Microsoft SQL Server管理对象(SMO)

SQL 2005: Here is the SMO main page: Microsoft SQL Server Management Objects (SMO)

下面是传输功能: 传输数据

如何:传输模式和数据从一个数据库到另一个在Visual Basic .NET