Recently I had an issue where a Web Application stopped working when a SQL Server Migration took place. The SQL Server was moved to a new physical server, but in addition to that they upgraded SQL Server from 2005 to 2008 R2. The problem turned out to be the SMO references in the source code. All applications written referencing previous versions of SMO need to be changed to reference the new SMO DLL’s.
As a minimum, you would need to add the following which are required for connection classes, SMO utility classes, and foundation classes:
According to Microsoft, the SmoEnum.dll has been removed and some namespaces have changed. You will need to include the following:
In Visual C#
using Microsoft.SqlServer.Management.Smo; using Microsoft.SqlServer.Management.Common;
In Visual Basic
Imports Microsoft.SqlServer.Management.Smo Imports Microsoft.SqlServer.Management.Common
Lastly, if your application uses the Urn functionality (for example Server.GetSqlSmoObject(Urn)) you will need to link to the Microsoft.SqlServer.Management.Sdk.Sfc namespace. If you use the Transfer object directly, you need to link to the Microsoft.SqlServer.Management.SmoExtended namespace. (Example of the Transfer object)
//Define a Transfer object and set the required options and properties. Transfer xfr; xfr = new Transfer(db); xfr.CopyAllTables = true; xfr.Options.WithDependencies = true; xfr.Options.ContinueScriptingOnError = true; xfr.DestinationDatabase = "AdventureWorks2012Copy"; xfr.DestinationServer = srv.Name; xfr.DestinationLoginSecure = true; xfr.CopySchema = true; //Script the transfer. Alternatively perform immediate data transfer // with TransferData method. xfr.ScriptTransfer();
Expect some code changes when you migrate code. The reason for this is that some features have been depreciated in the new DLL’s.
Latest posts by Dirk Strauss (see all)
- The Daily Six Pack: September 28, 2015 - 28 September, 2015 00:15:24
- The Daily Six Pack: September 25, 2015 - 25 September, 2015 00:15:05
- CloudBerry Backup Desktop Edition by CloudBerry Lab - 24 September, 2015 16:57:04
- Webucator – C# Online and Onsite Training Classes With Microsoft Certified Instructors - 23 September, 2015 20:34:25
- The Daily Six Pack: September 23, 2015 - 23 September, 2015 00:15:32