Why??? process cannot access the file because it is being used by another process

I have a web app I am running.  all of my other web pages work just fine and access the database just fine.  but when I click on a new page I get this error.  I can then go out and access other pages that access db just fine again.

I must add, the other pages use regular data calls, but this 'problem' page is using Linq.

I look in the sql log and see:


2010-04-20 18:03:28.90 Logon       Login failed for user 'WORKLAPTOP\username'. [CLIENT: <named pipe>]
2010-04-20 18:04:13.53 spid51      Error: 17207, Severity: 16, State: 1.
2010-04-20 18:04:13.53 spid51      FCB::Open: Operating system error 32(The process cannot access the file because it is being used by another process.) occurred while creating or opening file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\db1.mdf'. Diagnose and correct the operating system error, and retry the operation.

I did go into my:
C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS
and delete everything and restart.

thx.
purdyra1Asked:
Who is Participating?
 
Anthony PerkinsCommented:
>>I am not sure if this is the correct or best answer. <<
Than you should not have accepted my comment as a solution.  I have repeatedly told you what you are doing is risky at best, it is your right to disregard that information, but if that is the case you should not accept my solution and especially with a "C" grade.

I have asked an EE Moderator to review.
0
 
purdyra1Author Commented:
oh, also I look at the code as I walk thru it and the error I see is:

[0] = {System.Data.SqlClient.SqlError: Cannot open user default database. Login failed.}
[1] = {System.Data.SqlClient.SqlError: Login failed for user cpuname\username'.}
0
 
Anthony PerkinsCommented:
Please post your connection string.  I suspect you are trying to attach the database as opposed to merely opening it.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Anthony PerkinsCommented:
On second thoughts, does the default database for cpuname\username exist?  If not change it to a database that does exist, Master for example.
0
 
purdyra1Author Commented:
since I am using a sourcesafe I have to share the .mdf with the rest of the team, so I do have to keep attaching and detaching the mdf to check it in.  the default db was the db that we are using and I thought, well maybe behind the scenes this is causing problems, so I made the default db for the cpuname\username the Master Db, this way if I detach the db we are using it doesn't cause problems.

so to answer your question, the default db is Master.
0
 
purdyra1Author Commented:
I was told that linq doesn't look at the app.config file where the other connection string is. it has the same values either way.
this is from the Settings.settings file.

here is the connection string:

<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="example1.Core.Properties" GeneratedClassName="Settings">
  <Profiles />
  <Settings>
    <Setting Name="example1ConnectionString" Type="(Connection string)" Scope="Application">
      <DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>
<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <ConnectionString>Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\example1.mdf";Integrated Security=True;User Instance=True</ConnectionString>
  <ProviderName>System.Data.SqlClient</ProviderName>
</SerializableConnectionString></DesignTimeValue>
      <Value Profile="(Default)">Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\example1.mdf";Integrated Security=True;User Instance=True</Value>
    </Setting>
  </Settings>
</SettingsFile>
0
 
purdyra1Author Commented:
whoops, one of my examples above says  db1.mdf, and the other has example1.mdf.

I obviously am just replacing the real name of the db to something I am making up.  they should be the same and in my code they are. so ignore this oversight.
0
 
Anthony PerkinsCommented:
>>since I am using a sourcesafe I have to share the .mdf with the rest of the team, so I do have to keep attaching and detaching the mdf to check it in.<<
Then that is your problem.  There is simply no need to do that.  I am surprised you have not corrupted the database yet.
0
 
purdyra1Author Commented:
why does it work for the rest of our web pages except for this one page? besides the fact the others don't use Linq and this one does?

we are all working remotely on our machines at our homes, and due to the situation we have to have a local install of the .mdf file.
I have to download the changes to the .mdf from the other users, and to do that, I must detach the db or it won't let me download a file becz it's in use.

any other workarounds?
and I keep thinking to myself, it works just fine with the other pages just fine, except for this one page that uses Linq.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.