开发者

Programmatic backing up of DB's on SQL Server 2008 fails (but works on earlier versions) [duplicate]

开发者 https://www.devze.com 2023-03-19 01:11 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: SQL Server SMO complains of missing DLL
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

SQL Server SMO complains of missing DLL

I have the following code for backing up DB's which has worked with Windows Server 2003 on SQL Server 2005:

            ServerConnection ServerConn = new ServerConnection();
        try
        {
            ServerConn.ServerInstance = "(local)";
            ServerConn.LoginSecure = true;
            ServerConn.Connect();

      开发者_如何学Go      if (ServerConn.SqlConnectionObject.State == ConnectionState.Open)
            {
                Server svr = new Server(ServerConn);
                string[] DatabaseNames = GetDatabaseNames();
                foreach (string Database in DatabaseNames)
                {
                    Backup bkp = new Backup();
                    bkp.Devices.AddDevice(SanityConstants.DBBackupFolder + Database + ".bak", DeviceType.File);
                    bkp.Database = Database;
                    bkp.Action = BackupActionType.Database;
                    bkp.Initialize = true;
                    bkp.SqlBackup(svr);
                }
            }
        }

When this code is executed on a Windows Server 2008 32-bit machine, I get the following error:

"Backup failed for Server '[DT-COMP]'. -- Could not load file or assembly 'Microsoft.SqlServer.SqlEnum, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified."

SQL Server 2008 R2 is installed on this machine. I am able to replicate the issue on other Win Server 2008 machines.

Any ideas?


The Error you have shown is not due to the Code you have written, but its due to the SqlServer Installation Problem, Repair the SqlServer in your system and try again. And if it also not working stop the SqlServer and Start again, detach the database and re-attach it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号