I have copied a DB from one my computers and using it here. On trying to open the page which requires the fetching content from DB, on con.open I am getting this exception:
Unable to open the physical file "E:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\cakephp.mdf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)". Unable to open the physical file "E:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\cakephp_log.LDF". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)". Cannot open database "cakephp" requested by the login. The login failed. Login failed for user 'Sarin-PC\Sarin'.
I have attached the database from Management Studio Express 2008 and I have also checcked the connection string. Here it is:
<connectionStrings>
<add name="cn" connectionString="server=.\sqlexpress;database=cakephp;integrated security=true;uid=sarin;pwd=******"/>
</connectionStrings>
In Visual Studio, when I test the connection, it says "Test connection succeeded". However, there is one strange thing going on. When I login to the Management Studio, there is no + sign with the newly attached database, as shown.
If the full WebConfig is reqiured to be seen, I have pasted it here: http://pastebin.com/sVAuN0Ug
There are users of the database, but, there are also users of the server. One user has to have login rights to SqlServer before it can use the database.
In your case you copied the database and it's users, but those users don't have login permissions on the new server. Solution would be to add a new Login account on SqlServer (go to the Security node of the SqlServer, not the Security node of the database), and add it there. When you add that user, assign it to the database as well, and that should work.
Edit: After reading your issue further, is it possible that there are two sql servers targeting the same mdf file? Because that cannot work. Also, when copying database files, have you detached them before copying? If that's all fine, then try making backup and then restore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With