简体   繁体   English

数据库备份在调试中运行,但未发布

[英]DB Backup runs in Debug but not Release

I have a small c# wpf app for doing some simple calculations running off a Sql Express 2008 R2 db, and in the setup section is a backup button that runs the code 我有一个小型c#wpf应用程序,用于执行一些从Sql Express 2008 R2 db运行的简单计算,并且在设置部分中是运行代码的备份按钮。

                using (DTZDataContext db = new DTZDataContext())
                {
                    db.ExecuteCommand(string.Format("BACKUP DATABASE DtzDb TO DISK = '{0}'", filename));
                }

The connection string I am using is 我正在使用的连接字符串是

Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\DTZ.mdf;Integrated Security=True;User Instance=True;Database=DtzDb

I have confirmed there are no other open db connections at this point in the application and the backup runs fine in debug, but once I compile for release (running from VS or as standalone) I get the error: 我已经确认应用程序此时没有其他打开的db连接,并且备份在调试时运行良好,但是一旦编译发布(从VS或独立运行),我就会收到错误消息:

Operating system error 32 “32(failed to retrieve text for this error Reason 15105)” BACKUP DATABASE is terminating abnormally. 操作系统错误32“ 32(由于错误15105而无法检索文本)” BACKUP DATABASE异常终止。

How can I fix this, preferably without having to install Sql Management Studio on each machine and attaching the DB? 如何解决此问题,最好不必在每台计算机上都安装Sql Management Studio并附加数据库? What is the recommended way of doing backups? 推荐的备份方式是什么? Why does it work in Debug but not Release. 为什么它可以在Debug中工作,但不能在Release中工作。

Many Thanks 非常感谢

My bad... It turns out VS had changed the DataContext connection string to DTZConnectionString1 and made another settings file. 我的坏...事实证明VS已将DataContext连接字符串更改为DTZConnectionString1并进行了另一个设置文件。 Now I am using the correct connection string it is working fine. 现在我正在使用正确的连接字符串,它可以正常工作。

No idea why the incorrect one worked in debug but not release. 不知道为什么不正确的人可以在调试中工作但不能发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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