1

I'v built a program, and I used SQL. It worked fine but suddenly, without changing the code, I got the error message:

Error 3 Unable to copy file "C:\Users\user\documents\visual studio 2010\Projects\Programm\Programm\App_Data\DataBase_log.ldf" to "bin\Debug\App_Data\DataBase_log.ldf". The process cannot access the file 'C:\Users\user\documents\visual studio 2010\Projects\Programm\Programm\App_Data\DataBase_log.ldf' because it is being used by another process.

This is my connection string:

private string ConnectionString()
{
    return @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\DataBase.mdf;Initial Catalog=DataBase.mdf;Integrated Security=True;User Instance=True";
}

I'm using SQL server 2008 and Visual studio 2010. I can't figure out what the problem is and I'd appreciate anyone who helps.

4

1 回答 1

3

1) 有时 vslshost.exe 会从之前的运行中卡住,并且您无法再次构建,因为它打开了文件。有时另一个构建工作,有时您必须关闭 VS 并重新打开。其他时候你去删除这个过程。

2)如果数据库将在最终用户机器上,那么“.\SqlExpress”应该可以工作

于 2013-09-08T12:28:21.993 回答