We help IT Professionals succeed at work.

Server Error: Operating system error 32 in ASPX file with SQL server 2005 database link

Srinivas Mantha
Srinivas Mantha asked
on
I am new to ASP.NET 3.5 and learning through a standard book on the subject.  I am very familiar with traditional ASP and developed several successful projects with database links.

I am using visual studio 2008 on XP Professional (SP3) to develop webpages and testing on the local host.  
I created a SQL Server 2005 database (smdemo.mdf) from visual studio 2008 not from SQL server 2005 Management Studio.  

The test site folder (asp24hr) is located on
C:/inetpub/wwwroot/asp24hr
I testing using the command: http://localhost/asp24hr/nameofaspx file

The static pages are working fine.  But the aspx file with database link is not working and giving an error
http://localhost/asp24hr/databasedemo.aspx


The error is
Unable to open the physical file "C:\Inetpub\wwwroot\asp24hr\App_Data\smdemo.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 C:\Inetpub\wwwroot\asp24hr\App_Data\smdemo.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

I have gone through the web forums on the subject.  As per their instructions, I checked whether the mdf database file exists on Management Studio Express and login with an admin account.  But I do not see that file in the list of databases. Any thoughts how to resolve the problem
Comment
Watch Question

Srinivas ManthaConsultant Anesthesiologist and Pain Physician

Author

Commented:
The link is not useful. Any other specific help?

Commented:
try to add everyone permission to that folder and see if it helps
Srinivas ManthaConsultant Anesthesiologist and Pain Physician

Author

Commented:
I did. But the same problem is continuing.

Commented:
you said "I created a SQL Server 2005 database (smdemo.mdf) from visual studio 2008 not from SQL server 2005 Management Studio. "

Try to check if there is already a database with the same name in SQL.
To check, open SQL Management Studio and expand the databases node

If you found a database with the same name, you can:
1- delete the local database from APP_Data folder and change the connection string to point to the SQL database
2- delete the SQL database and keep your local databse in APP_Data folder

Hoep this help
Top Expert 2012

Commented:
There is simply no need to allow everyone permission to the database files.  That is at best a security risk and besides as you have discovered is ot the problem.

It sounds like you have already attached the database (but as indicated previously you should confirm this), so all you have to do is connect to it.  Try posting your connection string so that we can help you further.
Srinivas ManthaConsultant Anesthesiologist and Pain Physician

Author

Commented:
In my system, both SQL server 2005 and SQL server 2008 R2 are installed.  Will it cause such problems?. In SQL server 2008 R2  I am able to see only the configuration tools not the typical management studio as in 2005 version.  Should I uninstall In SQL server 2008 R2  ?
Top Expert 2012

Commented:
>>Will it cause such problems?<<
No.

>>I am able to see only the configuration tools not the typical management studio as in 2005 version.<<
Since you have already installed SQL Server, have you considered installing Management Studio?
Srinivas ManthaConsultant Anesthesiologist and Pain Physician

Author

Commented:
I will load the entire package of SQL server 2008 and see. It may take about 2 days.
Consultant Anesthesiologist and Pain Physician
Commented:
I identified the problem.  The problem is that I created the site with visual studio 2008 in file system (not HTTP through local host) and then try to open it through http:/localhost/websitefolder
after web sharing the folder. As I said earlier, I was using Window XP professional (SP3).  Obviously, the IIS server of windows is not permitting pages that are dependent on SQL server database installed on another server i.e ASP.NET development server of visual studio 2008.  After review of this comment by experts, this question may be closed.
Srinivas ManthaConsultant Anesthesiologist and Pain Physician

Author

Commented:
I identified the problem myself and posted about a week ago.  I invited comments from experts to verify my solution.