Hi ElactixNovae,
>> Unable to open the physical file "D:\Project\New folder\New folder\HOSPITAL_MANAGEMENT_SYSTEM_IN_C_WITH_SOURCE_CODE\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf". Operating system
error 5: "5(Access is denied.)".
According to your error message, your SQL server service account did not have the read and write permission on the folder D:\Project\New folder\New folder\HOSPITAL_MANAGEMENT_SYSTEM_IN_C_WITH_SOURCE_CODE\HospitalManagementSystem_C#\HospitalManagementSystemCSharp\HospitalManagementSystemCSharp\hospital.mdf".
Please try the follow steps to solve the issue.
1.
Find Service Account for SQL Server
2. Right click the (mdf/ldf) files or the folder and select “Properties”.
3. Select “Security” tab and click the “Edit” button.
4. Add SQL server service account and give this service account “Full control” to the file or the folder.
5. Click “OK” button.
6.Attach the db again,refer to the blog
Different methods to attach SQL Server MDF files
Please also make sure the location of the mdf file is correct.
Best regards,
Cathy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to
MSDN Support, feel free to contact MSDNFSF@microsoft.com