Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have install the SQL server 2008 R2 & configure the server Mixed mode authentication with username = 'sa' & password = 'pw'
and my attachment .mdf file is located in D:\TransparentTest\ForTest and service is running.

Now i connect the server2008 attachment .mdf file through coding but not connect. Error msg shown('Unable to open the physical file "D:\TransparentTest\ForTest\sd.mdf". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".
An attempt to attach an auto-named database for file D:\TransparentTest\ForTest\sd.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.')

My code is below :->
--------------------
C#
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=MachineName\MSSQLSERVER2008; AttachDbFilename=D:\TransparentTest\ForTest\sd.mdf;User Id=sa;Password=pw";
con.Open();


Above code is fine working in Sql Server2005, but not working in Sql Server2008.
How will i solve above problem???
Please help me proper instruction......
Posted
Updated 21-Jun-12 21:26pm
v2
Comments
Prasad_Kulkarni 22-Jun-12 3:28am    
You've already ask'd this question: To connect the attachment .mdf file through .net[^]
Don't re-post your questions, If you want to modify or update your question then use 'Improve question' widget. But don't re-post it.
Vani Kulkarni 22-Jun-12 4:27am    
Good observation!

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900