如何在退出应用程序后终止localdb进程

时间:2014-10-17 22:31:41

标签: .net winforms localdb

我正在开发winform应用程序。

我的数据库的连接字符串如下;

string _DatabaseFile = Path.GetDirectoryName(Application.ExecutablePath) + @"\Database\db.mdf";
                _DatabaseConnectionParams = String.Format(@"Data Source=(LocalDB)\v11.0;AttachDbFilename={0};Integrated Security=True", _DatabaseFile);

一切都很好。

但退出我的应用程序后SQL Server进程仍然有效。

哪种方法可以阻止SQL Server?

提前谢谢。

1 个答案:

答案 0 :(得分:2)

我认为你不需要做任何事情。

在关闭进程的最后一次连接后几分钟,它会自动关闭。

相关问题