I am using:
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
I am using the above namespaces for restore database from c# window form
, but the compiler tell me
The type or namespace name 'Management' does not exist in the namespace 'MicrosoftSqlServer' are you missing an assembly reference
And I follow some advice from Google, found the DLL
in C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies
:
Microsoft.SqlServer.Smo.dll;
Microsoft.SqlServer.ConnectionInfo.dll
and I copy them and paste them to all the location in my project, but I still have error message from compiler.
Could anyone where I can put the reference to?
The SQL Server Management Objects (SMO) Framework is a set of objects designed for programmatic management of Microsoft SQL Server and Microsoft Azure SQL Database.
Beginning with SQL Server 2017 SMO is distributed as the Microsoft.SqlServer.SqlManagementObjects
NuGet package to allow users to develop applications with SMO. This means it's no longer necessary to install the Microsoft SQL Server SDK as a separate install.
To install SMO as a NuGet Package:
First, open that Package Manager Console. In Visual Studio:
Tools
⯈ NuGet Package Manager
⯈ Package Manager Console
Use the console to install the Microsoft.SqlServer.SqlManagementObjects
NuGet package:
Install-Package Microsoft.SqlServer.SqlManagementObjects
Now, the SMO references are available as package references (Expand References for the given project):
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With