简体   繁体   中英

Get SQL Server 2000 instance path using C#

I need to relocate files to SQL Server 2000 default data folder programmatically using C#, I have searched a lot but couldn't find a solution.

Given below link only works for SQL Server 2005 and above versions. C# How to get SQL Server installation path programatically?

Please help me. Thanks in advance.

The "supported" way to do this would be to use DMO. The property you want is called SQLDataRoot :

The SQLDataRoot property identifies the default operating-system directory implementing storage for Microsoft SQL Server system user-defined databases.

The root of the DMO documentation is here

In fact, SMO (that was released with SQL Server 2005) supports connecting to SQL Server 2000, so you should use SMO for this task. The property you want there is, I believe, DefaultFile

This has the benefit that the same code should work against 2000,2005,2008 and 2008 R2 instances.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM